Parameter Domains

Domains can be assigned to rule method parameters with the attribute [Domain(value)], where value is a string. If value starts with "{", "instances", "(." or null, it is interpreted as a Cord domain expression. For more information, see Domain. If the rule method is static, then value must be a string that names one of the following:

  1. A public static method, where the containing class is also public. The method must be parameterless and the return value must be an IEnumerable<T>, where T is the type of the annotated parameter.

  2. A public static property with a get accessor, where the containing class is also public.

  3. A public static field in the class containing the Domain attribute, where the containing class is also public.

If the rule method is instance-based, the restrictions above apply with the exception that the method, property of field can be either static or instance-based.

Example

The following example shows how to use parameter domains.

public class C
{
   [Rule]
   static void MyParameterDomain([Domain("SomeInts")] int x)
   {
      /* ... */
   }
   public static IEnumerable<int> SomeInts()
   {
      return new int[] {1, 2, 3, 4};
   }
}

See Also

Reference

Domain
DomainAttribute

Concepts

Rule Attribute
Model Programs

Other Resources

Model Program Attributes