DomainAttribute Class
Namespace: Microsoft.Modeling
Assembly: Microsoft.Xrt.Runtime (in Microsoft.Xrt.Runtime.dll)
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};
}
}
Spec Explorer supports the following forms of domains for reference types:
[Domain("{null}")]
[Domain("instances(implementationType)")]
[Domain("{null} + instances(implementationType)")]
Domains can be assigned to rule method parameters with the Domain attribute. The Domain attribute takes one string parameter, domain.
If domain starts with "{", "instances", "(.", or null, it is interpreted as a Cord domain expression. If the rule method is static, then domain must be a string that names one of the following:
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>.
A public static property with a get accessor, where the containing class is also public.
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, or field can be either static or instance-based.
Note that the domain is specified in terms of the implementation type, not the model type. In practice, this usually does not matter, as the implementation type and model type are typically the same. However, if a model type has been bound to a different implementation type through the use of the TypeBinding attribute, domain is still specified in terms of the implementation type, but the associated model type will be used during model exploration.
For more information about using attributes, see Extending Metadata Using Attributes.
Development Platforms
Microsoft Windows 7, Microsoft Windows Vista, Microsoft Windows XP SP2 or later, Microsoft Windows Server 2008, Microsoft Windows Server 2003Reference
DomainAttribute MembersMicrosoft.Modeling Namespace
Other Resources
Parameter DomainsRule Attribute
Domain