Class FlowMessage
- Assembly
- Crosser.EdgeNode.Flows.Abstractions.dll
This is a customized version of the .NET System.Dynamic.DynamicObject. The object is mainly used to pass data between modules in a flow with the possibility to change/remove/add properties at runtime
[JsonConverter(typeof(FlowMessageJsonConverter))]
public class FlowMessage : DynamicObject, IFlowMessage, IDynamicMetaObjectProvider
- Inheritance
-
FlowMessage
- Implements
-
IFlowMessage
- Inherited Members
- Extension Methods
Examples
You can build any object by creating a new FlowMessage as a dynamic and just set properties
dynamic d = new FlowMessage();
d.name = "Harry The Hippo";
d.age = 35;
You can also build object with dot-notation.
dynamic o = new FlowMessage();
p.person.name = "Harry The Hippo";
d.person.age = 35;
Constructors
FlowMessage()
This constructor just works off the internal dictionary and any public properties of this object.
Note you can subclass FlowMessage.
public FlowMessage()
Fields
ALLOWED_CHARS
protected static readonly string ALLOWED_CHARS
Field Value
MESSAGE_PROPERTY
public const string MESSAGE_PROPERTY = "crosser.message"
Field Value
REGEX_ENDS_WITH_INDEX
protected const string REGEX_ENDS_WITH_INDEX = "\\[\\d+\\]$"
Field Value
REGEX_FIND_TEMPLATES
protected static readonly string REGEX_FIND_TEMPLATES
Field Value
REGEX_FIND_TEMPLATE_CONTENT
protected static readonly string REGEX_FIND_TEMPLATE_CONTENT
Field Value
REGEX_GET_ALL_INDEX
protected static readonly string REGEX_GET_ALL_INDEX
Field Value
REGEX_HAS_INDEX
protected const string REGEX_HAS_INDEX = "(\\[\\d+\\]*)+$"
Field Value
REGEX_VALID_PROPERTY
protected static readonly string REGEX_VALID_PROPERTY
Field Value
SUCCESS_PROPERTY
public const string SUCCESS_PROPERTY = "crosser.success"
Field Value
Properties
ENVIRONMENT_NAMES_SUPPORTED
A read-only dictionary that exposes the ENV_VARs available to use with template syntax.
public static IReadOnlyDictionary<string, string> ENVIRONMENT_NAMES_SUPPORTED { get; }
Property Value
ErrorMessage
public string ErrorMessage { get; }
Property Value
IsError
public bool IsError { get; }
Property Value
IsSuccess
public bool IsSuccess { get; }
Property Value
this[int]
public object? this[int index] { get; }
Parameters
indexint
Property Value
this[string]
public object? this[string key] { get; set; }
Parameters
keystring
Property Value
Properties
public Dictionary<string, object?> Properties { get; set; }
Property Value
_properties
public ImmutableSortedDictionary<string, object?> _properties { get; set; }
Property Value
Methods
AddAllProperties<T>(IFlowMessage?, string, T?, bool, bool)
[Obsolete("Use Set<T> instead")]
public void AddAllProperties<T>(IFlowMessage? message, string path, T? value, bool allowConvertToFlowMessage = true, bool autoCreate = true)
Parameters
Type Parameters
T
CanBeConvertedToFlowMessage(object?)
public static bool CanBeConvertedToFlowMessage(object? o)
Parameters
oobject
Returns
Clear()
public void Clear()
Clone()
Will return a new FlowMessage based on the properties dynamically added to the current object
public IFlowMessage Clone()
Returns
- IFlowMessage
ConvertTo(object?, Type)
public static dynamic? ConvertTo(object? obj, Type type)
Parameters
Returns
- dynamic
ConvertTo<T>(object?)
public static T? ConvertTo<T>(object? obj)
Parameters
objobject
Returns
- T
Type Parameters
T
Deserialize(string)
[Obsolete("USe Parse or TryParse instead")]
public static IFlowMessage Deserialize(string json)
Parameters
jsonstring
Returns
- IFlowMessage
GetByTemplate(string)
public IResult<string> GetByTemplate(string template)
Parameters
templatestring
Returns
- IResult<string>
GetByTemplate(string, Type)
public IResult<dynamic?> GetByTemplate(string template, Type type)
Parameters
Returns
- IResult<dynamic>
GetByTemplate<T>(string)
public IResult<T?> GetByTemplate<T>(string template)
Parameters
templatestring
Returns
- IResult<T>
Type Parameters
T
GetDynamicMemberNames()
Returns the enumeration of all dynamic member names.
public override IEnumerable<string> GetDynamicMemberNames()
Returns
- IEnumerable<string>
A sequence that contains dynamic member names.
GetProperties()
public IEnumerable<KeyValuePair<string, object?>> GetProperties()
Returns
GetProperty<T>(IFlowMessage, string)
[Obsolete("Use Get<T>")]
public T? GetProperty<T>(IFlowMessage message, string path)
Parameters
messageIFlowMessagepathstring
Returns
- T
Type Parameters
T
GetValue<T>(string)
public T? GetValue<T>(string path)
Parameters
pathstring
Returns
- T
Type Parameters
T
Get<T>(IFlowMessage, string)
public T? Get<T>(IFlowMessage message, string path)
Parameters
messageIFlowMessagepathstring
Returns
- T
Type Parameters
T
Get<T>(string)
public T? Get<T>(string path)
Parameters
pathstring
Returns
- T
Type Parameters
T
Has(IFlowMessage, string)
public bool Has(IFlowMessage message, string path)
Parameters
messageIFlowMessagepathstring
Returns
Has(string)
public bool Has(string path)
Parameters
pathstring
Returns
HasOwnProperty(IFlowMessage, string)
[Obsolete("Use Has instead")]
public bool HasOwnProperty(IFlowMessage message, string path)
Parameters
messageIFlowMessagepathstring
Returns
HasOwnProperty(string)
Check if the object has a property with a specific path defined
[Obsolete("Use Has instead")]
public bool HasOwnProperty(string path)
Parameters
pathstringThe property-name to look for
Returns
HasOwnProperty<T>(IFlowMessage, string)
[Obsolete("Use Has<T> instead")]
public bool HasOwnProperty<T>(IFlowMessage message, string path)
Parameters
messageIFlowMessagepathstring
Returns
Type Parameters
T
HasOwnProperty<T>(string)
Check if the object has a property with a specific path and type defined
[Obsolete("Use Has<T> instead")]
public bool HasOwnProperty<T>(string path)
Parameters
pathstring
Returns
Type Parameters
TThe expected type of the property
Has<T>(IFlowMessage, string)
public bool Has<T>(IFlowMessage message, string path)
Parameters
messageIFlowMessagepathstring
Returns
Type Parameters
T
Has<T>(string)
public bool Has<T>(string path)
Parameters
pathstring
Returns
Type Parameters
T
IsComplex(object)
[Obsolete("Use CanBeConvertedToFlowMessage(object o) instead")]
public static bool IsComplex(object o)
Parameters
oobject
Returns
Parse(string)
public static IFlowMessage Parse(string json)
Parameters
jsonstring
Returns
- IFlowMessage
Parse(string, string)
Use this if you are not sure what kind of JSON you have. If JSOn is an array for example this is needed instead of the basic FlowMessage.Parse
public static IFlowMessage Parse(string path, string json)
Parameters
Returns
- IFlowMessage
Exceptions
Remove(string)
public IFlowMessage Remove(string path)
Parameters
pathstring
Returns
- IFlowMessage
RemoveProperty(string)
[Obsolete("Use Remove instead")]
public void RemoveProperty(string path)
Parameters
pathstring
Set(string, string, bool, bool)
public IFlowMessage Set(string path, string value, bool allowConvertToFlowMessage = true, bool autoCreate = true)
Parameters
Returns
- IFlowMessage
SetError(string)
public void SetError(string message = "")
Parameters
messagestring
SetSuccess()
public void SetSuccess()
SetValue<T>(string, T?, bool, bool)
public void SetValue<T>(string path, T? value, bool allowConvertToFlowMessage = true, bool autoCreate = true)
Parameters
Type Parameters
T
Set<T>(string, T?, bool, bool)
public IFlowMessage Set<T>(string path, T? value, bool allowConvertToFlowMessage = true, bool autoCreate = true)
Parameters
Returns
- IFlowMessage
Type Parameters
T
ToJSON()
public string ToJSON()
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
TryGetMember(GetMemberBinder, out object?)
Provides the implementation for operations that get member values. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations such as getting a value for a property.
public override bool TryGetMember(GetMemberBinder binder, out object? result)
Parameters
binderGetMemberBinderProvides information about the object that called the dynamic operation. The
binder.Nameproperty provides the name of the member on which the dynamic operation is performed. For example, for theConsole.WriteLine(sampleObject.SampleProperty)statement, wheresampleObjectis an instance of the class derived from the DynamicObject class,binder.Namereturns "SampleProperty". Thebinder.IgnoreCaseproperty specifies whether the member name is case-sensitive.resultobjectThe result of the get operation. For example, if the method is called for a property, you can assign the property value to
result.
Returns
- bool
true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)
TryParse(string, out IFlowMessage)
public static bool TryParse(string json, out IFlowMessage flowMessage)
Parameters
jsonstringflowMessageIFlowMessage
Returns
TryParse(string, string, out IFlowMessage)
Use this if you are not sure what kind of JSON you have. If JSOn is an array for example this is needed instead of the basic FlowMessage.Parse
public static bool TryParse(string path, string json, out IFlowMessage flowMessage)
Parameters
Returns
TrySetMember(SetMemberBinder, object?)
Will set Crosser.EdgeNode.Common.Utilities.Json.CrosserDynamicObject.Properties binder.Name to the value passed in
public override bool TrySetMember(SetMemberBinder binder, object? value)
Parameters
binderSetMemberBindervalueobject