Partilhar via


ModelingAssembly Attribute

By default, a Cord script can reference model programs in the same Visual Studio project. To make model programs that are located in another assembly accessible to a Cord script, the ModelingAssembly attribute must be used in that other assembly. A Cord reference can then occur across assembly boundaries. Once the ModelingAssembly attribute is declared anywhere in a project, the assembly generated from that project thereby becomes a model program assembly within the solution. The designation applies to the entire assembly of that project and not just to a given model program type that is in the project.

Example

In the following C# model program, the ModelingAssembly attribute is used to designate the project's assembly as a model program assembly. Thus for example, AnotherModelProgram can be referenced by a Cord script in another assembly.

using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Microsoft.Modeling;

[assembly: Microsoft.Modeling.ModelingAssembly()]

static class AnotherModelProgram
{
   static int accumulator;

   [Rule(Action = "Add(x)")]
   static void AddRule(int x)
   {
      Condition.IsTrue(x > 0);
      accumulator += x;
   }
   // ... other rules ...
}

See Also

Reference

ModelingAssemblyAttribute

Concepts

Model Programs

Other Resources

Model Program Attributes