MethodAttribute class

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

If applied to a public method of the source object, marks it as an in-rule method. The method must return a value type and be parameterless or have only parameters of source object type or any value type supported by Code Effects (qualified method). This attribute can also be applied to a qualified method of any other public class in order to be usable as an in-rule method. In this case the source object must be decorated with ExternalMethodAttribute which references this method by name and class type.

Syntax

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class MethodAttribute : System.Attribute,
	CodeEffects.Rule.Attributes.IDescribableAttribute

Properties

  • Description Type: System.String

    Gets or sets the description of the in-rule method. Rule authors can see this description when they hover the mouse over the in-rule method 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.

  • DisplayName Type: System.String

    Gets or sets the display name of the in-rule method in Rule Editor. Use this property to "represent" in-rule methods if the method name is not descriptive enough for non-technical rule authors, or if you need to use several overloads of the same method as different in-rule methods. It's not advisable to use this property in multilingual applications; instead, use culture-specific custom Source XML documents. This property is optional. The default value is the declared name of the qualified method.

  • IncludeInCalculations Type: System.Bool

    Used only in in-rule methods that return numeric type, and ignored in all other in-rule methods. Gets or sets the value indicating whether the in-rule method can be included in calculations. This property is optional. The default value is True.

Notes

This attribute is optional. Its purpose is to provide the ability to set the DisplayName and optional Description values for in-rule methods. Code Effects component uses any qualified method of the source object as an in-rule method unless it's decorated with the ExcludeFromEvaluationAttribute. If applied to a non-qualified method, an exception will be thrown. All non-qualified methods that are not decorated with the MethodAttribute will be ignored.

Example

using CodeEffects.Rule.Attributes;

namespace TestLibrary
{
	public class Person
	{
		[Field(DisplayName = "First name", Max = 30)]
		public string FirstName { get; set; }

		[Field(DisplayName = "Last name", Max = 30)]
		public string LastName { get; set; }

		[Method("Full name")]
		public string GetFullName()
		{
			return string.Format("{0}, {1}", this.LastName, this.FirstName);
		}
	}
}
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: