Skip to content

Commit 925c160

Browse files
authored
Update create-rules-engine-project.md
Changes to code
1 parent 0347dc2 commit 925c160

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

articles/logic-apps/rules-engine/create-rules-engine-project.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ To reuse existing rules from Microsoft BizTalk Server, you can export them. Howe
277277
The **<*function-name*>.cs** file also includes the **`ILogger`** interface, which provides support for logging events to an Application Insights resource. You can send tracing information to Application Insights and store that information alongside the trace information from your workflows. The **<*function-name*>.cs** file also includes the **`FileStoreRuleExplorer`** object that accesses the ruleset. As you can observe, the constructor for the **`FileStoreRuleExplorer`** uses the **`loggerFactory`** to send telemetry information also to Application Insights:
278278

279279
```csharp
280-
private readonly ILogger<RulesFunction> logger;
280+
private readonly ILogger<RulesFunction> logger;
281281

282282
private FileStoreRuleExplorer ruleExplorer;
283283

@@ -297,17 +297,17 @@ private readonly ILogger<RulesFunction> logger;
297297

298298
For this example, the ruleset file is called **`SampleRuleSet.xml`**, which was created using either the **Microsoft Rules Composer** or exported using **Microsoft BizTalk Server**.
299299

300-
```csharp
301-
var ruleSet = this.ruleExplorer.GetRuleSet(ruleSetName);
302-
303-
// Check if ruleset exists
304-
if(ruleSet == null)
305-
{
306-
// Log an error in finding the rule set
307-
this.logger.LogCritical($"RuleSet instance for '{ruleSetName}' was not found(null)");
308-
throw new Exception($"RuleSet instance for '{ruleSetName}' was not found.");
309-
}
310-
```
300+
```csharp
301+
var ruleSet = this.ruleExplorer.GetRuleSet(ruleSetName);
302+
303+
// Check if ruleset exists
304+
if(ruleSet == null)
305+
{
306+
// Log an error in finding the rule set
307+
this.logger.LogCritical($"RuleSet instance for '{ruleSetName}' was not found(null)");
308+
throw new Exception($"RuleSet instance for '{ruleSetName}' was not found.");
309+
}
310+
```
311311

312312
> [!IMPORTANT]
313313
>
@@ -323,36 +323,36 @@ private readonly ILogger<RulesFunction> logger;
323323

324324
After the engine runs, the facts' values are overwritten with the values that result from the engine execution:
325325

326-
```csharp
327-
// Create rule engine instance
328-
var ruleEngine = new RuleEngine(ruleSet: ruleSet);
326+
```csharp
327+
// Create rule engine instance
328+
var ruleEngine = new RuleEngine(ruleSet: ruleSet);
329329

330-
// Create a typedXml Fact(s) from input xml(s)
331-
XmlDocument doc = new XmlDocument();
332-
doc.LoadXml(inputXml);
333-
var typedXmlDocument = new TypedXmlDocument(documentType, doc);
330+
// Create a typedXml Fact(s) from input xml(s)
331+
XmlDocument doc = new XmlDocument();
332+
doc.LoadXml(inputXml);
333+
var typedXmlDocument = new TypedXmlDocument(documentType, doc);
334334

335-
// Initialize .NET facts
336-
var currentPurchase = new ContosoNamespace.ContosoPurchase(purchaseAmount, zipCode);
335+
// Initialize .NET facts
336+
var currentPurchase = new ContosoNamespace.ContosoPurchase(purchaseAmount, zipCode);
337337

338-
// Provide facts to rule engine and run it
339-
ruleEngine.Execute(new object[] { typedXmlDocument, currentPurchase });
338+
// Provide facts to rule engine and run it
339+
ruleEngine.Execute(new object[] { typedXmlDocument, currentPurchase });
340340

341-
// Send the relevant results(facts) back
342-
var updatedDoc = typedXmlDocument.Document as XmlDocument;
343-
```
341+
// Send the relevant results(facts) back
342+
var updatedDoc = typedXmlDocument.Document as XmlDocument;
343+
```
344344

345345
1. The engine uses the **`RuleExecutionResult`** custom class to return the values to the **`RunRules`** method:
346346

347-
```csharp
348-
var ruleExectionOutput = new RuleExecutionResult()
347+
```csharp
348+
var ruleExectionOutput = new RuleExecutionResult()
349349
{
350350
XmlDoc = updatedDoc.OuterXml,
351351
PurchaseAmountPostTax = currentPurchase.PurchaseAmount + currentPurchase.GetSalesTax()
352352
};
353-
353+
354354
return Task.FromResult(ruleExectionOutput);
355-
```
355+
```
356356

357357
1. Replace the sample function code with your own, and edit the default **`RunRules`** method for your own scenarios.
358358

0 commit comments

Comments
 (0)