Compartir a través de


RuleAttribute Class

Indicates that a method, constructor, or property is a rule for a model program and associates the rule with an action invocation.

Namespace: Microsoft.Modeling
Assembly: Microsoft.Xrt.Runtime (in Microsoft.Xrt.Runtime.dll)

Usage

'Usage

Syntax

'Declaration
[AttributeUsageAttribute(AttributeTargets.Constructor|AttributeTargets.Method|AttributeTargets.Property, AllowMultiple=false, Inherited=true)] 
public sealed class RuleAttribute : Attribute

Example

The following example shows an action declaration in Cord and a corresponding action invocation in a C# model program.

// An action declaration within a Cord config block.
action static abstract int Implementation.Sum(int x);
static int stateTotal;

// An action invocation within a model program.
[Rule(Action = "Sum(op) / result")]
static int AddtoTotal(int op)
{
    return stateTotal += op;
}

Remarks

When Spec Explorer explores a machine defined in Cord script, Spec Explorer creates the transition system for the machine by iteratively examining available, unexplored states.

For a machine that includes or references a model program construct, Spec Explorer generates a transition from a state for a rule if all the rule's conditions are satisfied for the state. If a rule contains any conditions that are not satisfied for the state, the rule does not generate a transition from that state.

A rule can generate more than one transition from a state. For each transition that the rule generates, Spec Explorer labels the transition with the action invocation associated with the rule. States and action invocations can contain symbolic elements. A labeled transition is called a step.

To explicitly associate a rule with an action, set the Action named parameter when you apply the RuleAttribute attribute. If you do not provide an Action named parameter when you apply the Rule attribute, then Spec Explorer uses the name and parameter list of the member to which the Rule attribute is applied to identify the action associated with the rule. For a list of initial property values for an instance of the Rule attribute, see the RuleAttribute constructor. For more information about rules and actions, see Rules and Actions.

For more information about using attributes, see Extending Metadata Using Attributes.

Inheritance Hierarchy

System.Object
   System.Attribute
    Microsoft.Modeling.RuleAttribute

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Microsoft Windows 7, Microsoft Windows Vista, Microsoft Windows XP SP2 or later, Microsoft Windows Server 2008, Microsoft Windows Server 2003

Change History

See Also

Reference

RuleAttribute Members
Microsoft.Modeling Namespace

Other Resources

Actions
Model Programs
Rules
Rule Attribute
Parameter Generation
Exploration
Steps