Table of Contents

Class FlowMessage

Namespace
Crosser.EdgeNode.Flows.Models.Abstractions.Models
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

string

MESSAGE_PROPERTY

public const string MESSAGE_PROPERTY = "crosser.message"

Field Value

string

REGEX_ENDS_WITH_INDEX

protected const string REGEX_ENDS_WITH_INDEX = "\\[\\d+\\]$"

Field Value

string

REGEX_FIND_TEMPLATES

protected static readonly string REGEX_FIND_TEMPLATES

Field Value

string

REGEX_FIND_TEMPLATE_CONTENT

protected static readonly string REGEX_FIND_TEMPLATE_CONTENT

Field Value

string

REGEX_GET_ALL_INDEX

protected static readonly string REGEX_GET_ALL_INDEX

Field Value

string

REGEX_HAS_INDEX

protected const string REGEX_HAS_INDEX = "(\\[\\d+\\]*)+$"

Field Value

string

REGEX_VALID_PROPERTY

protected static readonly string REGEX_VALID_PROPERTY

Field Value

string

SUCCESS_PROPERTY

public const string SUCCESS_PROPERTY = "crosser.success"

Field Value

string

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

IReadOnlyDictionary<string, string>

ErrorMessage

public string ErrorMessage { get; }

Property Value

string

IsError

public bool IsError { get; }

Property Value

bool

IsSuccess

public bool IsSuccess { get; }

Property Value

bool

this[int]

public object? this[int index] { get; }

Parameters

index int

Property Value

object

this[string]

public object? this[string key] { get; set; }

Parameters

key string

Property Value

object

Properties

public Dictionary<string, object?> Properties { get; set; }

Property Value

Dictionary<string, object>

_properties

public ImmutableSortedDictionary<string, object?> _properties { get; set; }

Property Value

ImmutableSortedDictionary<string, object>

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

message IFlowMessage
path string
value T
allowConvertToFlowMessage bool
autoCreate bool

Type Parameters

T

CanBeConvertedToFlowMessage(object?)

public static bool CanBeConvertedToFlowMessage(object? o)

Parameters

o object

Returns

bool

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

obj object
type Type

Returns

dynamic

ConvertTo<T>(object?)

public static T? ConvertTo<T>(object? obj)

Parameters

obj object

Returns

T

Type Parameters

T

Deserialize(string)

[Obsolete("USe Parse or TryParse instead")]
public static IFlowMessage Deserialize(string json)

Parameters

json string

Returns

IFlowMessage

GetByTemplate(string)

public IResult<string> GetByTemplate(string template)

Parameters

template string

Returns

IResult<string>

GetByTemplate(string, Type)

public IResult<dynamic?> GetByTemplate(string template, Type type)

Parameters

template string
type Type

Returns

IResult<dynamic>

GetByTemplate<T>(string)

public IResult<T?> GetByTemplate<T>(string template)

Parameters

template string

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

IEnumerable<KeyValuePair<string, object>>

GetProperty<T>(IFlowMessage, string)

[Obsolete("Use Get<T>")]
public T? GetProperty<T>(IFlowMessage message, string path)

Parameters

message IFlowMessage
path string

Returns

T

Type Parameters

T

GetValue<T>(string)

public T? GetValue<T>(string path)

Parameters

path string

Returns

T

Type Parameters

T

Get<T>(IFlowMessage, string)

public T? Get<T>(IFlowMessage message, string path)

Parameters

message IFlowMessage
path string

Returns

T

Type Parameters

T

Get<T>(string)

public T? Get<T>(string path)

Parameters

path string

Returns

T

Type Parameters

T

Has(IFlowMessage, string)

public bool Has(IFlowMessage message, string path)

Parameters

message IFlowMessage
path string

Returns

bool

Has(string)

public bool Has(string path)

Parameters

path string

Returns

bool

HasOwnProperty(IFlowMessage, string)

[Obsolete("Use Has instead")]
public bool HasOwnProperty(IFlowMessage message, string path)

Parameters

message IFlowMessage
path string

Returns

bool

HasOwnProperty(string)

Check if the object has a property with a specific path defined

[Obsolete("Use Has instead")]
public bool HasOwnProperty(string path)

Parameters

path string

The property-name to look for

Returns

bool

HasOwnProperty<T>(IFlowMessage, string)

[Obsolete("Use Has<T> instead")]
public bool HasOwnProperty<T>(IFlowMessage message, string path)

Parameters

message IFlowMessage
path string

Returns

bool

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

path string

Returns

bool

Type Parameters

T

The expected type of the property

Has<T>(IFlowMessage, string)

public bool Has<T>(IFlowMessage message, string path)

Parameters

message IFlowMessage
path string

Returns

bool

Type Parameters

T

Has<T>(string)

public bool Has<T>(string path)

Parameters

path string

Returns

bool

Type Parameters

T

IsComplex(object)

[Obsolete("Use CanBeConvertedToFlowMessage(object o) instead")]
public static bool IsComplex(object o)

Parameters

o object

Returns

bool

Parse(string)

public static IFlowMessage Parse(string json)

Parameters

json string

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

path string
json string

Returns

IFlowMessage

Exceptions

NullReferenceException

Remove(string)

public IFlowMessage Remove(string path)

Parameters

path string

Returns

IFlowMessage

RemoveProperty(string)

[Obsolete("Use Remove instead")]
public void RemoveProperty(string path)

Parameters

path string

Set(string, string, bool, bool)

public IFlowMessage Set(string path, string value, bool allowConvertToFlowMessage = true, bool autoCreate = true)

Parameters

path string
value string
allowConvertToFlowMessage bool
autoCreate bool

Returns

IFlowMessage

SetError(string)

public void SetError(string message = "")

Parameters

message string

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

path string
value T
allowConvertToFlowMessage bool
autoCreate bool

Type Parameters

T

Set<T>(string, T?, bool, bool)

public IFlowMessage Set<T>(string path, T? value, bool allowConvertToFlowMessage = true, bool autoCreate = true)

Parameters

path string
value T
allowConvertToFlowMessage bool
autoCreate bool

Returns

IFlowMessage

Type Parameters

T

ToJSON()

public string ToJSON()

Returns

string

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

binder GetMemberBinder

Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the DynamicObject class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.

result object

The 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

json string
flowMessage IFlowMessage

Returns

bool

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

path string
json string
flowMessage IFlowMessage

Returns

bool

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

binder SetMemberBinder
value object

Returns

bool