Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
VariablesOutput.cs
1using System;
2using System.Reflection;
3using System.Text;
5
7{
12 {
13 private static readonly TypeInfo variablesTypeInfo = typeof(Variables).GetTypeInfo();
14 private const string recursionMarker = " IsExporting ";
15
21 public Grade Supports(Type Object) => variablesTypeInfo.IsAssignableFrom(Object.GetTypeInfo()) ? Grade.Ok : Grade.NotAtAll;
22
28 public string GetString(object Value)
29 {
31
32 if (Variables.ContainsVariable(recursionMarker))
33 return Value.GetType().FullName;
34
35 Variables[recursionMarker] = true;
36
37 StringBuilder sb = new StringBuilder();
38 bool First = true;
39
40 sb.Append('(');
41
42 foreach (Variable Variable in Variables)
43 {
44 if (First)
45 First = false;
46 else
47 sb.Append(';');
48
49 sb.Append(Variable.Name);
50 sb.Append(":=");
52 }
53
54 sb.Append(')');
55
56 Variables.Remove(recursionMarker);
57
58 return sb.ToString();
59 }
60 }
61}
Class managing a script expression.
Definition: Expression.cs:39
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Definition: Expression.cs:4496
Converts values of type Variables to expression strings.
string GetString(object Value)
Gets a string representing a value.
Grade Supports(Type Object)
If the interface understands objects such as Object .
Contains information about a variable.
Definition: Variable.cs:10
object ValueObject
Object Value of variable.
Definition: Variable.cs:88
string Name
Name of variable.
Definition: Variable.cs:78
Collection of variables.
Definition: Variables.cs:25
virtual bool ContainsVariable(string Name)
If the collection contains a variable with a given name.
Definition: Variables.cs:76
virtual bool Remove(string VariableName)
Removes a varaiable from the collection.
Definition: Variables.cs:147
Interface for custom string output classes. Converts objects of a given type to an expression string.
Grade
Grade enumeration
Definition: Grade.cs:7