Recently I have been working a lot with the BizTalk Rules Engine (BRE) that comes along with Biztalk Server 2004.
Rather than the more common approach of using the BRE inside a BizTalk Orchestration passing in XML messages, I have been working with the rules engine in a pure .net scenario passing in .net objects as facts and working with a long term fact creator.
This approach uses the available API to call the BRE inside .net and passes in an array of facts to be operated on. The long term fact is used on the policy and loaded into memory the first time the policy is called. The supplied facts are passed out of the called policy with updated / changed values based on the rules inside the policy. This is very similar to a ByRef call.
I have put together simple sample that calls the BRE inside .net code using .net objects as facts and a long term fact creator. Make sure you read the ReadMe.txt file for additional set up information.
Sample: Biztalk Business Rules With .Net Components Sample
Basically, to run the sample build the two .net assemblies and GAC them. Then, load the Rule Policy XML using the Rules Engine Deployment Wizard. Run the WinForm. Note it may take up to 60 seconds for the policy to first be callable – to bypass this just restart the RuleEngineUpdateService (because you are not really working with BizTalk unless you have to restart a windows service).
The Long Term Fact will be created once each time you load the form – so if you keep hitting run the LTF gets reused. I have code commented out that will write to the event log when the LTF is created.