RuleAPI:Procedural commands/Using

From FlexRule Wiki
Jump to: navigation, search

Summary

A signature may contain some Type parameters that can be defined by this command.

This command can be used in all logic: Procedural, Decision Table, Flow, Workflow, Natural Language, Validation and Decision.

Parameters

  1. path
    1. Description: Full address of a type including name space and type name. Or a ruleset address to a model.
    2. Mandatory: Yes
    3. Type: String
  2. name
    1. Description: If not specified, the last part of path will be used, otherwise this can override the name of type.
    2. Mandatory: No (its better to specify an assembly)
    3. Type: String
  3. assembly
    1. Description: Assembly name (including .dll) that has the type implementation
    2. Mandatory: No
    3. Type: String
  4. function
    1. Description: Indicates if the path is an address to type holding multiple functions
    2. Mandatory: No
    3. Type: Boolean (true/false)

Sample

  1. <Declaration>
  2.     <Using path="System.DateTime"/>
  3. </Declaration>

Custom Type and Assembly

The following, will register type Entities.Publications.PublicationCollection in an assembly named entities.dll with a new name of List.

  1. <Declaration>
  2.     <Using assembly="Entities.dll" path="Entities.Publications.PublicationCollection" name="List"/>
  3. </Declaration>

The following, will import a type MyNamespace.MyType in an assembly named MyAssembly.dll:

  1. <Declaration>
  2.     <Using assembly="MyAssembly.dll" path="MyNamespace.MyType" />
  3. </Declaration>

Which then allows you to call static members by referring to MyType in your logic.

Logic as Function

The following sample registers a procedural logic as a function in some other model.

  1. <Declaration>
  2.     <Using path="DataAccessLogicProcedure.xml" function="true" return="list" name="loadDataFromDb" />
  3. </Declaration>

This registers logic in the model called "DataAccessLogicProcedure" that has an output parameter named "list" as a function. So in the current context, you can use it as shown in the following format:

  1.  <Var value="result = loadDataFromDb('Select * from cars')" />