Show Navigation
Next Topic »
ParameterAttribute class
Namespace: CodeEffects.Rule.Attributes
IMPORTANT NOTE #1 Generic methods with generic array params cannot be used as in-rule methods or rule actions.
IMPORTANT NOTE #2 Generic methods with generic params cannot be used in Source XML as in-rule methods or rule actions. Use plain .Net class(es) if your source object declares generic methods.
If applied to a parameter of a qualified method, marks it as a parameter of a rule action or an in-rule method. To qualify, this parameter must be of source object type or any value type supported by Code Effects. It can also be a collection. Methods with non-qualified parameters are ignored by Rule Editor.
Syntax
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
public class ParameterAttribute : System.Attribute,
CodeEffects.Rule.Attributes.ISettingsAttribute
Properties
-
CollectionItemType
Type: System.Type
Used only with qualified parameters of non-generic collection type whose underlying type cannot be determined at run-time (qualified collection). This property is ignored for parameters of other types and generic collections. Gets or sets the underlying type of the qualified collection. An example of a qualified collection would be the System.Collections.Specialized.StringCollection or System.Collections.ArrayList. This property is optional. The entire method is ignored if the value of this property for any of the qualified parameters of qualified collection type is not set.
-
DataSourceName
Type: System.String
Used only with rule action or in-rule method parameters of System.Int type, and ignored for parameters of other types. Gets or sets the unique name of the Dynamic Menu Data Source declared by the SourceAttribute on the source object. If set, the rule author can only select the value from the menu of items supplied by the data source method.
-
DateTimeFormat Type: System.String
Used only with qualified parameters of date and time types, and ignored by parameters of other types. Gets or sets the date or time format of the qualified parameter. You can use standard .NET date and time formatting. This property is not used during rule evaluation, and is optional. The default date format is "MMM dd, yyyy", and the default time format is "hh:mm tt".
-
Description Type: System.String
Gets or sets the description of the parameter. Rule authors can see this description when they hover the mouse over the parameter element in the Rule Editor. The value of this property is ignored if RuleEditor.ShowDescriptionsOnMouseHover is set to False. It's not advisable to use this property in multilingual applications; instead, use culture-specific custom Source XML documents. This property is optional.
-
Filter
Type: System.String
Gets or sets the name of the menu filter of the parameterd in the Rule Editor. This property is optional.
Please refer to FieldAttribute topic for details on menu filtering feature.
-
Max Type: System.Int64
Used only with qualified parameters of numeric and string types, and is ignored by parameters of other types. For numeric parameters, gets or sets the maximum value that rule authors can enter manually. For string parameters, gets or sets the maximum length of the string that rule authors can type as the value. Setting this value has no effect on rule evaluation. This property is optional.
-
Min Type: System.Int64
Used only with qualified parameters of numeric type, and is ignored by parameters of other types. Gets or sets the minimum value of the qualified parameter that rule authors can enter manually. Using this value has no effect on rule evaluation. This property is optional.
-
ValueInputType Type: CodeEffects.Rule.Common.ValueInputType
Gets or sets the value indicating whether the qualified parameter should only be typed in manually, or it should only accept fields of a certain type, or both. For example, consider the in-rule method DoSomething( John ). The parameter John is a string that the rule author typed in. This is a value entered by the "user", i.e. it's of type ValueInputType.User. The same in-rule method can be expressed as DoSomething( MiddleName ) The parameter MiddleName is a field, so this parameter was selected by the rule author as a "field" item from the menu, i.e. it's of type ValueInputType.Fields. This property is optional. The default value is ValueInputType.All, which allows both User and Fields input types.
Notes
In the rule ...
If Get credit score( SSN ) is less than 640 then Decline( Bad credit )
... the Get credit score is an in-rule method, the SSN is its parameter and can be customized with the ParameterAttribute, the 640 is the value element that can be customized with the ReturnAttribute (i.e. the return value of in-rule method), the Decline is an action and Bad credit is the action's parameter that can also be customized with the ParameterAttribute class. See the source object topic for details on in-rule methods and actions.
In-rule methods and rule actions can have parameterless signatures or declare any number of qualified parameters. Parameters can be customized in a manner similar to fields but with fewer options.
If a method takes only parameter of source type, such a method is displayed to rule authors as a rule field (display name with no signature parentheses). For example, consider a fictitious source object and three overloads of the Action method, declared in some Helper class and referenced by the source object with ExternalActionAttribute:
using CodeEffects.Rule.Common;
using CodeEffects.Rule.Attributes;
namespace TestLibrary
{
[ExternalAction(typeof(Helper), "Action")]
public class DoerOfThings
{
[Field(Max = 30)]
public string Something { get; set; }
}
public class Helper
{
[Action("Action One")]
public void Action()
{
}
[Action("Action Two")]
public void Action(DoerOfThings source)
{
}
[Action("Action Three")]
public void Action(
[Parameter(ValueInputType.User)]
int number)
{
}
}
}
Action One takes no parameters; rule authors will see it as a field when the DoerOfThings is given to Rule Editor as its source object:
If Something is test 1 then Action One and ...
Action Two takes a single parameter of type DoerOfThings. This class is a source object for this rule. During evaluation Rule Evaluator passes the instance of the source object to the action. This is a very powerful feature of Code Effects. See the source object topic for details on rule actions. Rule Editor also displays the Action Two as a field - no need to bother rule authors with parameters unless it's necessary.
... else if Something is test 2 then Action Two and ...
Action Three takes one integer parameter:
... else Action Four(123)
Post your questions on
Stackoverflow and become a part of our growing community
Comments:
0
|
|