ParameterAttribute class

Namespace: CodeEffects.Rule.Attributes
Assembly: CodeEffects.Rule.dll

If applied to a parameter of a qualified method, marks it as a parameter of a rule action or an in-rule method. This parameter must be of source object type or any value type supported by Code Effects (qualified parameter).

Syntax

[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
public sealed class ParameterAttribute : System.Attribute

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.

  • ConstantValue Type: System.String

    Gets or sets the constant value that Code Effects should pass to the method as a parameter when it evaluates the rule. Setting this property to any value signals Code Effects not to display this parameter on the UI when the rule author adds the in-rule method or action to the rule. If this is the only parameter, the in-rule method or action will appear in the UI as "parameterless", i.e. as a regular field.

  • DataSourceName Type: System.String

    Used only in rule action or in-rule method parameters that represent System.Int parameters of qualified .NET methods, and is 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 parameter value is "MMM dd, yyyy", and the default time parameter value 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.

  • 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. Used by Code Effects only in the UI, it 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. Used by Code Effects only in the UI, it 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.

Method parameters can also be marked as constant by setting the ConstantValue property to any value. This "hides" such parameters from rule authors, always passing the specified constant value to the method during rule evaluation. If a method contains only constant parameters or parameters of source type, such a method is displayed to rule authors as a rule field. For example, consider a fictitious source object and four 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.All, ConstantValue = "ABC")]
			string text)
		{
			// ...
		}

		[Action("Action Four")]
		public void Action(
			[Parameter(ValueInputType.All, ConstantValue = "XYZ")]
			string text,
			[Parameter(ValueInputType.User)]
			int number)
		{
			// ...
		}
	}
}

Action One takes no parameters; rule authors will see it as a field when the DoerOfThings is given to Code Effects component as its source object:

If Something is "test 1" then Action One ...

Action Two takes only one parameter of type DoerOfThings. This class is a source object for this rule. During rule evaluation Code Effects component 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. Code Effects component 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 ...

Action Three takes one parameter of type System.String which is decorated as a constant parameter. Code Effects component hides such parameters from rule authors as well, passing the constant value set by ParameterAttribute to the action during rule evaluation.

... else if Something is "test 3" then Action Three ...

Action Four takes two parameters: a constant string and a regular integer. Code Effects component hides the constant parameter but displays the regular integer, asking the rule author for the input (notice the ValueInputType.User attribute). The value "XYZ" is passed to the Helper.Action method as its first parameter during rule evaluation.

... else Action Four([123])
Post your support requests on Stackoverflow.com. You can also post your comments and product feedback using the form at the bottom of this page.
Comments: 0
Name (optional):
Comment (URLs are allowed and must start with http:// or https://; all tags will be encoded):
Remaining character count: