Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class Foo
{
public string Bar;
}
/*..................*/
public class FooBarRule : Rule
{
public override void Define()
{
Foo foo = null;
When()
.Match<Foo>(() => foo);
Then()
.Action(_ =>
Console.WriteLine("Activated {0}", foo.Bar), ActionTrigger.Activated)
.Action(_ =>
Console.WriteLine("Reactivated {0}", foo.Bar), ActionTrigger.Reactivated)
.Action(_ =>
Console.WriteLine("Deactivated {0}", foo.Bar), ActionTrigger.Deactivated);
}
}
/*..................*/
{
// Somewhere in Main
Foo foo = new Foo();
foo.Bar = "Baz";
session.Insert(foo);
session.Fire();
foo.Bar = "Zab";
session.Update(foo);
session.Fire();
session.Retract(foo);
session.Fire();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment