Navigation

Categories
Show Navigation Next Topic  »

RuleModel class

Namespace: CodeEffects.Rule.Models
Assembly: CodeEffects.Rule.dll

Provides a data model for authoring and validating complex business rules in an MVC environment.

Syntax

[System.ComponentModel.TypeConverter(
	typeof(CodeEffects.Rule.Models.RuleDataTypeConverter))]
public partial class RuleModel

Properties

  • Desc Type: System.String

    Gets or sets the value of the rule description entered by the rule author into the Description text box of the Toolbar.

  • Id Type: System.String

    Gets or sets the Id of the rule that is being handled. Note that Code Effects component assigns IDs to all new rules automatically using string representations of System.Guid. Those IDs are stored in Rule XML. The only time you need to overwrite this value is when your system uses its own rule IDs.

  • IsLoadedRuleOfEvalType Type: System.Nullable<System.Boolean>

    Gets or sets the value indicating whether the rule that is being handled is of evaluation type. Obviously, a value of False means that the rule is of execution type. This property helps when you store different types of rules in different locations. A value of null indicates that Code Effects component doesn't know the type of the rule.

  • Name Type: System.String

    Gets or sets the value of the rule name entered by the rule author into the Name text box of the Toolbar.

  • SkipNameValidation Type: System.Boolean

    Gets or sets the value indicating whether the Code Effects component should skip validation of the rule name when the rule author uses the Toolbar to save or update a rule. The default value is False.

Methods

  • BindSource(System.String, System.String) Returns: System.Void
    Parameters:
    • sourceAssembly, System.String - The full name of the assembly that contains the declaration of the source object. You can obtain the full name of the source object's assembly by executing Assembly.GetAssembly( SourceObjectType ).FullName.
    • sourceType, System.String - The full name of the source object type. You can obtain the source object's full name by executing sourceObjectInstance.GetType().FullName.

    Binds the instance of the RuleModel to the type of the source object. Calling this method is a required step when saving a rule inside of SaveAction in MVC. See the MVC demo project for a SaveAction implementation example.

  • BindSource(System.String) Returns: System.Void
    Parameters:
    • sourceXmlFile, System.String - The full path to the custom XML file that describes the source object. In Code Effects, this document is called Source XML.

    Binds the instance of the RuleModel to the type of the source object. Calling this method is a required step when saving a rule inside of the SaveAction in MVC. See the MVC demo project for a SaveAction implementation example.

  • BindSource(System.Type) Returns: System.Void
    Parameters:

    Binds the instance of the RuleModel to the type of the source object. Calling this method is a required step when saving a rule inside of the SaveAction in MVC. See the MVC demo project for a SaveAction implementation example.

  • Create(System.String, System.String, System.String) Returns: RuleModel
    Parameters:
    • ruleXml, System.String - Rule Xml as a string.
    • sourceAssembly, System.String - The full name of the assembly that contains the declaration of the source object. You can obtain the full name of the source object's assembly by executing Assembly.GetAssembly( SourceObjectType ).FullName.
    • sourceType, System.String - The full name of the source object type. You can obtain the source object's full name by executing sourceObjectInstance.GetType().FullName.

    Creates an instance of the RuleModel, binds it to the type of the source object and loads the Rule XML. Calling this method is a required step when loading a rule using the LoadAction in MVC. See the MVC demo project for an implementation example.

  • Create(System.String, System.Type) Returns: RuleModel
    Parameters:
    • ruleXml, System.String - Rule Xml as a string.
    • sourceType, System.Type - The type of the source object.

    Creates an instance of the RuleModel, binds it to the type of the source object, and loads the Rule XML. Calling this method is a required step when loading a rule using the LoadAction in MVC. See the MVC demo project for an implementation example.

  • Create(System.String, System.Xml.XmlDocument) Returns: RuleModel
    Parameters:
    • ruleXml, System.String - Rule Xml as a string.
    • sourceXml, System.Xml.XmlDocument - The Source XML loaded in the XmlDocument.

    Creates an instance of the RuleModel, binds it to the type of the source object, and loads the Rule XML. Calling this method is a required step when loading a rule using the LoadAction in MVC. See the MVC demo project for an implementation example.

  • Create(System.String, System.String) Returns: RuleModel
    Parameters:
    • sourceAssembly, System.String - The full name of the assembly that contains the declaration of the source object. You can obtain the full name of the source object's assembly by executing Assembly.GetAssembly( SourceObjectType ).FullName.
    • sourceType, System.String - The full name of the source object type. You can obtain the source object's full name by executing sourceObjectInstance.GetType().FullName.

    Creates an instance of the RuleModel, binds it to the type of the source object, and loads the Rule XML. Calling this method is a required step when deleting a rule using the DeleteAction in MVC. See the MVC demo project for an implementation example.

  • Create(System.String) Returns: RuleModel
    Parameters:
    • sourceXmlFile, System.String - The full path to the custom XML file that describes the source object. In Code Effects, this document is called Source XML.

    Creates an instance of the RuleModel, binds it to the type of the source object, and loads the Rule XML. Calling this method is a required step when deleting a rule using the DeleteAction in MVC. See the MVC demo project for an implementation example.

  • Create(System.Type) Returns: RuleModel
    Parameters:

    Creates an instance of the RuleModel, binds it to the type of the source object, and loads the Rule XML. Calling this method is a required step when deleting a rule using the DeleteAction in MVC. See the MVC demo project for an implementation example.

  • GetRuleXml() Returns: System.String
    Parameters: None

    Returns a string that contains the XML document of the rule currently shown in the Rule Editor. Call the IsValid() method to verify that the current rule is valid before calling this method, otherwise an InvalidRuleException will be thrown. Use the returned string to store the rule in a database as an XML type or in a file system as an XML file. This is the string that you pass to all evaluation classes to evaluate your rule. You also use this string to load the rule into the Rule Editor for editing and deletion.

  • IsEmpty() Returns: System.Boolean
    Parameters: None

    Returns the a value indicating whether the Rule Editor is empty (contains no rule elements).

  • IsValid() Returns: System.Boolean
    Parameters: None

    Returns a value indicating whether the submitted rule passed automatic rule validation. You must call this method to trigger the validation. If validation fails, this method marks the submitted rule invalid and returns False.
    IMPORTANT! This overload does not perform the reusable rules circular references check. Use it only if you're certain that the submitted rule does not reference other rules.

  • IsValid(CodeEffects.Rule.Core.GetRuleDelegate) Returns: System.Boolean
    Parameters:
    • getRuleDelegate, CodeEffects.Rule.Common.GetRuleDelegate - A delegate that takes rule ID and returns XML of that rule.

    Returns a value indicating whether the submitted rule passed automatic rule validation. You must call this method to trigger the validation. If validation fails, this method marks the submitted rule invalid and returns False. This overload does perform the reusable rules circular references check, provided that the GetRuleDelegate value is not null.


Post your questions on Stackoverflow and become a part of our growing community

Comments: 0