ExternalMethodAttribute class

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

If applied to a source object, references an external public method 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).

Syntax

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class ExternalMethodAttribute : System.Attribute,
	CodeEffects.Rule.Attributes.IExternalAttribute

Properties

  • Assembly Type: System.String

    Gets or sets the full name of the assembly that declares the method class, which can be obtained by executing Assembly.GetAssembly( className ).FullName. If the Type property is not set, this property is required.

  • Method Type: System.String

    Gets or sets the name of the in-rule method declared outside of the source object. This is a required property.

  • Type Type: System.Type

    Gets or sets the type of the class that declares the external in-rule method. If the Assembly and TypeName properties are not set, this property is required.

  • TypeName Type: System.String

    Gets or sets the full name of the type of the class that declares the external in-rule method, which can be obtained by executing typeof( className ).FullName. If the Type property is not set, this property is required.

Notes

This attribute is optional. Its purpose is to provide references to in-rule methods declared outside of the source object. An exception will be thrown if this attribute points to a non-qualified method. If the external method declares multiple overloads, decorate each overload that you would like to use as an in-rule method with the MethodAttribute and set its DisplayName property to a unique display name.

Example

using System;
using CodeEffects.Rule.Attributes;

namespace TestLibrary
{
	// The source object references an 
	// external method declared in the Helper class
	[ExternalMethod(typeof(Helper), "GetFullName")]
	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; }
	}

	public class Helper
	{
		[Method("Full name", "Joins first and last names")]
		public string GetFullName(Person person)
		{
			return string.Format(
				"{0}, {1}", person.LastName, person.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: