Geeks With Blogs

News
Paul's Petrov Whiteboard [BizTalk, Enterprise Application Integration, Business Process Automation, SOA, .NET]

Let's say we have to implement simple scenario:

IF 

Fact.A equal N

THEN

Create new Fact. (Where fact is some .NET type, for instance BusinessObject)

 

In Business Rules Composer (BRC) we would use Assert() function with fact's type initializer as parameter: simply drug and drop BusinessObject constructor from class browser onto Assert’s argument placeholder.

Following this logic in BRE API one would do the same as we do for regular class members, i.e.:

//- create class binding

ClassBinding cbBO = new ClassBinding(typeof(BusinessObject));

//- create member binding (to constructor)

ClassMemberBinding cmbBO_ctor = new ClassMemberBinding("BusinessObject", cbBO);

..

//- conditions and rule creation omitted for brevity

..

//- assert new instance in the memory as a result of rule execution

actions.Add(new Assert(new UserFunction(cbmBO_ctor)));

 

This compiles but won’t work! Exception will be thrown that class member BusinessObject is not found. The trick is BRC uses CreateObject function under the hood for constructor invocation rather than regular member binding. And this function is not shown in the Rule Composer. So all of the above can be replaced with the following line:

 

actions.Add(new Assert(new CreateObject(typeof(BusinessObject))));

 

Of course, if you want to do something with newly asserted fact you still need to have class and appropriate member bindings for that.

Posted on Wednesday, November 30, 2005 5:37 PM BizTalk | Back to top


Comments on this post: Asserting new fact instance of .NET type using Business Rule Engine API

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Paul Petrov | Powered by: GeeksWithBlogs.net