ScriptStack 1.0.0
A .NET scripting language
Lade ...
Suche ...
Keine Treffer
ScriptStack.Runtime.Routine Klassenreferenz

A Routine is an abstract representation of a method. Mehr ...

Öffentliche Methoden

 Routine (Type result, string name, List< Type > parameters)
 
 Routine (Type result, string name, List< Type > parameterTypes, string description)
 
 Routine (string name)
 
 Routine (string name, string description)
 
 Routine (Type result, string name)
 
 Routine (Type result, string name, string description)
 
 Routine (Type result, string name, Type parameter)
 
 Routine (Type result, string name, Type parameter, string description)
 
 Routine (Type result, string name, Type parameter0, Type parameter1)
 
 Routine (Type result, string name, Type parameter0, Type parameter1, string description)
 
 Routine (Type result, string name, Type parameter0, Type parameter1, Type parameter2)
 
 Routine (Type result, string name, Type parameter0, Type parameter1, Type parameter2, string description)
 
void Verify (List< object > parameters)
 Verify the parameter types of a Routine. If null or void was specified values arent verified.
 
void Verify (object result)
 Verify the result of a Routine. If null or void was specified values arent verified.
 
override string ToString ()
 
string Description ()
 

Propertys

string Name [get]
 
List< Type > ParameterTypes [get]
 
Type Result [get]
 
Host Handler [get, set]
 

Private Methoden

void Validate (Type type)
 
string ToString (Type type)
 

Private Attribute

string name
 
List< Type > parameters
 
Type result
 
string description
 
Host host
 

Ausführliche Beschreibung

A Routine is an abstract representation of a method.

To successfully write a routine you have to use one of its several overloaded cunstuctors listed above and pass up to a maximum of 3 parameters.

Routine myRoutine;
myRoutine = new Routine(
typeof(int), // return value (optional)
"myFunction", // name of the function (required)
typeof(int), typeof(float), typeof(bool), // up to 3 parameters (optional)
"Describe your custom method" // a description (optional)
);
A Routine is an abstract representation of a method.
Definition Routine.cs:70

To declare more then 3 parameters you can add them to a list and add the list as parameter

// create a generic list ..
List<Type> customParameter = new List<Type>();
// .. add all parameter types
customParameter.Add(typeof(int));
customParameter.Add(typeof(float));
customParameter.Add(typeof(bool));
customParameter.Add(typeof(int));
// .. and add them as a parameter
Routine myRoutine = new Routine(
typeof(int),
"myFunction",
typeof(customParameter), // the list as parameter
"Describe your function"
);

The Manager can invoke a Routine by using the Invoke method.

Routine myRoutine = manager.Routines["print"];
List<object> parameters = new List<object>();
parameters.Add("Hello world");
myRoutine.Handler.Invoke(myRoutine.Name, parameters);
Host Handler
Definition Routine.cs:322
string Name
Definition Routine.cs:307
object Invoke(string routine, List< object > parameters)
Called when a Routine is invoked.
Siehe auch
Manager, Host
Noch zu erledigen
The Constructor has serveral (way too much) Overloaders

Beschreibung der Konstruktoren und Destruktoren

◆ Routine() [1/12]

ScriptStack.Runtime.Routine.Routine ( Type result,
string name,
List< Type > parameters )
136 {
137
139
140 foreach (Type parameter in parameters)
141 Validate(parameter);
142
143 this.result = result;
144 this.name = name;
145 this.parameters = parameters;
146
147 host = null;
148
149 }
Host host
Definition Routine.cs:78
void Validate(Type type)
Definition Routine.cs:84
string name
Definition Routine.cs:74
List< Type > parameters
Definition Routine.cs:75
Type result
Definition Routine.cs:76

Benutzt ScriptStack.Runtime.Routine.host, ScriptStack.Runtime.Routine.name, ScriptStack.Runtime.Routine.parameters, ScriptStack.Runtime.Routine.result und ScriptStack.Runtime.Routine.Validate().

◆ Routine() [2/12]

ScriptStack.Runtime.Routine.Routine ( Type result,
string name,
List< Type > parameterTypes,
string description )
152 {
153
155
156 foreach (Type parameter in parameterTypes)
157 Validate(parameter);
158
159 this.result = result;
160 this.name = name;
161 this.parameters = parameterTypes;
162 this.description = description;
163 host = null;
164
165 }
string description
Definition Routine.cs:77

Benutzt ScriptStack.Runtime.Routine.description, ScriptStack.Runtime.Routine.host, ScriptStack.Runtime.Routine.name, ScriptStack.Runtime.Routine.result und ScriptStack.Runtime.Routine.Validate().

◆ Routine() [3/12]

ScriptStack.Runtime.Routine.Routine ( string name)
167 : this(null, name, new List<Type>())
168 {
169 }

◆ Routine() [4/12]

ScriptStack.Runtime.Routine.Routine ( string name,
string description )
171 : this(null, name, new List<Type>(), description)
172 {
173 }

◆ Routine() [5/12]

ScriptStack.Runtime.Routine.Routine ( Type result,
string name )
175 : this(result, name, new List<Type>())
176 {
177 }

◆ Routine() [6/12]

ScriptStack.Runtime.Routine.Routine ( Type result,
string name,
string description )
179 : this(result, name, new List<Type>(), description)
180 {
181 }

◆ Routine() [7/12]

ScriptStack.Runtime.Routine.Routine ( Type result,
string name,
Type parameter )
183 : this(result, name, new List<Type>())
184 {
185 parameters.Add(parameter);
186 }

Benutzt ScriptStack.Runtime.Routine.parameters.

◆ Routine() [8/12]

ScriptStack.Runtime.Routine.Routine ( Type result,
string name,
Type parameter,
string description )
188 : this(result, name, new List<Type>(), description)
189 {
190 parameters.Add(parameter);
191 }

Benutzt ScriptStack.Runtime.Routine.parameters.

◆ Routine() [9/12]

ScriptStack.Runtime.Routine.Routine ( Type result,
string name,
Type parameter0,
Type parameter1 )
193 : this(result, name, new List<Type>())
194 {
195 parameters.Add(parameter0);
196 parameters.Add(parameter1);
197 }

Benutzt ScriptStack.Runtime.Routine.parameters.

◆ Routine() [10/12]

ScriptStack.Runtime.Routine.Routine ( Type result,
string name,
Type parameter0,
Type parameter1,
string description )
199 : this(result, name, new List<Type>(), description)
200 {
201 parameters.Add(parameter0);
202 parameters.Add(parameter1);
203 }

Benutzt ScriptStack.Runtime.Routine.parameters.

◆ Routine() [11/12]

ScriptStack.Runtime.Routine.Routine ( Type result,
string name,
Type parameter0,
Type parameter1,
Type parameter2 )
205 : this(result, name, new List<Type>())
206 {
207 parameters.Add(parameter0);
208 parameters.Add(parameter1);
209 parameters.Add(parameter2);
210 }

Benutzt ScriptStack.Runtime.Routine.parameters.

◆ Routine() [12/12]

ScriptStack.Runtime.Routine.Routine ( Type result,
string name,
Type parameter0,
Type parameter1,
Type parameter2,
string description )
212 : this(result, name, new List<Type>(), description)
213 {
214 parameters.Add(parameter0);
215 parameters.Add(parameter1);
216 parameters.Add(parameter2);
217 }

Benutzt ScriptStack.Runtime.Routine.parameters.

Dokumentation der Elementfunktionen

◆ Description()

string ScriptStack.Runtime.Routine.Description ( )

◆ ToString() [1/2]

override string ScriptStack.Runtime.Routine.ToString ( )
268 {
269
270 StringBuilder sb = new StringBuilder();
271
272 //if(result != (Type)null)
273 sb.Append(ToString(result) + " ");
274
275 sb.Append(name);
276
277 sb.Append("(");
278
279 int i = 0;
280
281 for (i = 0; i < parameters.Count; i++)
282 {
283
284 if (i > 0)
285 sb.Append(", ");
286
287 sb.Append(ToString(parameters[i]));
288
289 }
290
291 sb.Append(")");
292
293 return sb.ToString();
294
295 }
override string ToString()
Definition Routine.cs:267

Benutzt ScriptStack.Runtime.Routine.name, ScriptStack.Runtime.Routine.parameters, ScriptStack.Runtime.Routine.result und ScriptStack.Runtime.Routine.ToString().

Wird benutzt von ScriptStack.Runtime.Routine.ToString().

◆ ToString() [2/2]

string ScriptStack.Runtime.Routine.ToString ( Type type)
private
103 {
104
105 string tmp = "";
106
107 if (type == null)
108 tmp = "null";
109 else if (type == typeof(void))
110 tmp = "void";
111 else if (type == typeof(int))
112 tmp = "int";
113 else if (type == typeof(float))
114 tmp = "float";
115 else if (type == typeof(double))
116 tmp = "double";
117 else if (type == typeof(bool))
118 tmp = "bool";
119 else if (type == typeof(char))
120 tmp = "char";
121 else if (type == typeof(string))
122 tmp = "string";
123 else if (type == typeof(ArrayList))
124 tmp = "array";
125 else
126 tmp = type.ToString().Replace("System.", "").ToLower();
127
128 return tmp;
129
130 }
Definition ArrayList.cs:10

◆ Validate()

void ScriptStack.Runtime.Routine.Validate ( Type type)
private
85 {
86
87 if (type == null || type == typeof(void))
88 return;
89
90 if (type != typeof(int)
91 && type != typeof(float)
92 && type != typeof(bool)
93 && type != typeof(double)
94 && type != typeof(string)
95 && type != typeof(char)
96 && type != typeof(ArrayList)
97 )
98 throw new ExecutionException("Der Typ '" + type.Name + "' ist kein generischer Datentyp und es wurden keine Erweiterungen registriert.");
99
100 }
Definition ExecutionException.cs:10

Wird benutzt von ScriptStack.Runtime.Routine.Routine() und ScriptStack.Runtime.Routine.Routine().

◆ Verify() [1/2]

void ScriptStack.Runtime.Routine.Verify ( List< object > parameters)

Verify the parameter types of a Routine. If null or void was specified values arent verified.

Parameter
parameters
224 {
225
226 if (parameters.Count != this.parameters.Count)
227 throw new ExecutionException("Die Routine '" + name + "' wurde mit " + parameters.Count + " statt erwarteten " + this.parameters.Count + " Parametern aufgerufen.");
228
229 for (int i = 0; i < parameters.Count; i++)
230 {
231
232 if (null == this.parameters[i] || null == parameters[i])
233 continue;
234
235 if (typeof(void) == this.parameters[i] || typeof(void) == parameters[i])
236 continue;
237
238 Type expected = this.parameters[i];
239
240 Type specified = parameters[i].GetType();
241
242 if (expected != specified)
243 throw new ExecutionException("Typ '" + specified.Name + "' statt erwartetem Typ '" + expected.Name + "' als " + (i + 1) + " Parameter von '" + name +"' angegeben.");
244
245 }
246
247 }

Benutzt ScriptStack.Runtime.Routine.name und ScriptStack.Runtime.Routine.parameters.

Wird benutzt von ScriptStack.Runtime.Interpreter.INV().

◆ Verify() [2/2]

void ScriptStack.Runtime.Routine.Verify ( object result)

Verify the result of a Routine. If null or void was specified values arent verified.

Parameter
result
254 {
255
256 if (null == this.result || null == result)
257 return;
258
259 if (typeof(void) == this.result || typeof(void) == result)
260 return;
261
262 if (result.GetType() != this.result)
263 throw new ExecutionException("Typ '" + result.GetType().Name + "' statt erwartetem Typ '" + this.result.Name + "' als Ergebnis von '" + name + "' erhalten.");
264
265 }

Benutzt ScriptStack.Runtime.Routine.name und ScriptStack.Runtime.Routine.result.

Dokumentation der Datenelemente

◆ description

string ScriptStack.Runtime.Routine.description
private

◆ host

Host ScriptStack.Runtime.Routine.host
private

◆ name

◆ parameters

◆ result

Dokumentation der Propertys

◆ Handler

Host ScriptStack.Runtime.Routine.Handler
getset
322 {
323 get { return host; }
324 internal set { host = value; }
325 }

Wird benutzt von ScriptStack.Runtime.Interpreter.INV().

◆ Name

string ScriptStack.Runtime.Routine.Name
get
307 {
308 get { return name; }
309 }

Wird benutzt von ScriptStack.Runtime.Interpreter.INV().

◆ ParameterTypes

List<Type> ScriptStack.Runtime.Routine.ParameterTypes
get

◆ Result

Type ScriptStack.Runtime.Routine.Result
get
317 {
318 get { return result; }
319 }

Die Dokumentation für diese Klasse wurde erzeugt aufgrund der Datei: