A typical model program uses the NModel, NModel.Attributes,
and NModel.Execution namespaces. All of these are provided by the library
NModel.dll. A model program is compiled to a library, for example, by a command
like this one (where DEVPATH is an environment variable that stores the path to
the directory that contains the library, e.g., C:\Program Files\NModel\bin):
csc /t:library /r:"%DEVPATH%\NModel.dll" NewsReaderUI.cs
We code each model program in its own namespace. A model program consists
of the actions and variables defined by the types declared in its namespace. The
namespace name is the model program name: NewsReader in this example. A model
program can include more than one class (or other types); this simple example has
just one class.
NewsReader declares some variables to store the state, some methods to implement
the actions, and some methods to test when each action is enabled. That??™s all there
is to a model program. A model program does not have a main method or any other
control structure for invoking the actions.
We recommend coding model programs with no access modifiers, so most types
and members have the default private access. The tools can access private types and
members (using a mechanism we will describe in Chapter 6).
5.4.2 State variables
The state variables of the model program are the static fields and instance fields declared
in the model program??™s namespace.
Pages:
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110