Compartir a través de


FeatureAttribute Class

Indicates that a class belongs to a named feature.

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

Usage

'Usage

Syntax

'Declaration
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=false, Inherited=false)] 
public sealed class FeatureAttribute : Attribute

Example

The following code illustrates the use of the FeatureAttribute. The first block is Cord code, the second is the model program.

/// Contains actions of the model, bounds, and switches.
config Actions 
{
    switch KeepOutputParametersUnexpanded = false;
    switch StepBound = 128;
    switch PathDepthBound = 128;

    action static void Implementation.SwitchRunning();
    action static void Implementation.SwitchMode();
    switch testclassbase = "vs";
}

/// Constructs a machine from the model program. 
/// Since the model is not finite, this machine explodes
/// and exploration is stopped by a bound.
machine BasicCalculator() : Actions
{
     construct model program
        where scope = "CalculatorModel",
              features = "RunningMode"
}

/// Defines a scenario for slicing.
machine ScientificCalculator(): Actions
{
    construct model program
         where scope = "CalculatorModel",
               features = "RunningMode, ScientificMode"
}
namespace CalculatorModel
{
    /// <summary>
    /// An example model program.
    /// </summary>

  [Feature("RunningMode")]
  public static class RunningMode
  {
      // State variable
      public static bool running;
  
      // Actions
      [Rule(Action = "SwitchRunning()")]
      public static void SwitchRunning()
      {
          running = !running;
      }
  }

  [Feature("ScientificMode")]
  public static class ScientificMode
  {
      static bool scientific;
      
      [Rule(Action = "SwitchMode()")]
      public static void SwitchMode()
      {
          Condition.IsTrue(RunningMode.running);
          // action enabled only when running is true
          scientific = !scientific;
      }
   }
}

Remarks

Classes defined within a model program can be labeled as belonging to named feature sets using the [Feature(name)] attribute (where name is a string value). A feature is a named grouping of related state variables and rules representing a submodel of the overall model program.

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

Inheritance Hierarchy

System.Object
   System.Attribute
    Microsoft.Modeling.FeatureAttribute

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

FeatureAttribute Members
Microsoft.Modeling Namespace

Other Resources

Feature Attribute