Skip to content

Add a filter on the GetSnapshot method #110

@fredericcarre

Description

@fredericcarre

The XComponent Runtime supports natively lambda expressions to filter state machines instances according their public members properties. The idea of this feature is to extend the GetSnapshot method to add this lambda expression.

Example:

Imagine a public member with the property "Id".
We want all state machines matching a specific Id:
myComponentStm.GetSnapshot("Id == 1234")

The filter can be checked with the following code:
public static void CheckFilter(string filter) where T : class
{
try
{
var dynamicExpression = System.Linq.Dynamic.DynamicExpression.ParseLambda(new[] { Expression.Parameter(typeof(T)) }, typeof(bool), filter, new object[0]);
dynamicExpression.Compile();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions