Prerequisites: A valid Entity
Namespaces: InRule.Runtime
Classes: Entity
See Also: Retrieving a Rule Application, Creating a RuleSession, Creating Entities
Loading state from a file
// Load the state by passing in the path & filename.
mortgageEntity.LoadXml("Mortgage.xml");
Loading state from an XML string
// Load state from an XML string.
mortgageEntity.ParseXml("<Mortgage><LoanInfo><Principal>500000</Principal><APR>7</APR><TermInYears>30</TermInYears></LoanInfo><PaymentSummary /></Mortgage>");
Manually wiring up an Entity
//create ruleapp entities
Entity mortgageEntity = ruleSession.CreateEntity("Mortgage");
Entity loanInfo = ruleSession.CreateEntity("LoanInfo");
Entity paymentSummary = ruleSession.CreateEntity("PaymentSummary");
//set loanInfo values
loanInfo.Fields["Principal"].Value = 250000;
loanInfo.Fields["APR"].Value = 5.25;
loanInfo.Fields["TermInYears"].Value = 30;
//associate loanInfo entity to an Mortgage entity field
mortgageEntity.Fields["LoanInfo"].Value = loanInfo;
//associate paymentSummary entity to Mortgage entity field
mortgageEntity.Fields["PaymentSummary"].Value = paymentSummary;
Note: In order to use object-based state, the rule application must first be bound to a .NET assembly schema. See Binding to a .NET Assembly Schema in the main InRule Help file.
Comments
0 comments
Please sign in to leave a comment.