2using System.Collections.Generic;
3using System.Reflection;
4using System.Threading.Tasks;
15 private static readonly Dictionary<string, ISimulationNode> nodeTypes =
new Dictionary<string, ISimulationNode>();
16 private static readonly Dictionary<string, KeyValuePair<string, Assembly>> schemas =
new Dictionary<string, KeyValuePair<string, Assembly>>();
17 private static bool initialized =
false;
26 object[] Arguments =
new object[] {
null,
null };
30 TypeInfo TI = T.GetTypeInfo();
35 string Key = Node.Namespace +
"#" + Node.
LocalName;
37 if (nodeTypes.ContainsKey(Key))
38 throw new Exception(
"A class handling " + Key +
" has already been registered.");
40 nodeTypes[Key] = Node;
43 if (!schemas.ContainsKey(s))
44 schemas[s] =
new KeyValuePair<string, Assembly>(Node.
SchemaResource, TI.Assembly);
59 return schemas.TryGetValue(Namespace, out Result);
74 throw new NotSupportedException(
"Factory not initialized.");
76 Key = Definition.NamespaceURI +
"#" + Definition.LocalName;
78 throw new Exception(
"Unable to instantiate objects of type " + Definition.NamespaceURI +
"#" + Definition.LocalName);
80 Result = Result.Create(Parent,
Model);
81 await Result.FromXml(Definition);
Factory of simulation objects.
static void Initialize()
Initializes the factory
static async Task< ISimulationNode > Create(XmlElement Definition, ISimulationNode Parent, Model Model)
Creates a simulation objected, based on its XML definition.
static bool TryGetSchemaResource(string Namespace, out KeyValuePair< string, Assembly > Result)
Tries to get the embedded resource name of the schema defining a namespace, and the corresponding ass...
Root node of a simulation model
Static class that dynamically manages types and interfaces available in the runtime environment.
static Type[] GetTypesImplementingInterface(string InterfaceFullName)
Gets all types implementing a given interface.
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
string Namespace
XML Namespace where the element is defined.
string LocalName
Local name of XML element defining contents of class.
string SchemaResource
Points to the embedded XML Schema resource defining the semantics of the XML namespace.