/* # Creates an instance of a component. # createComponent: (name, component, metadata, callback) -> # implementation = component # unless implementation # return callback new Error "Component #{name} not available" # # If a string was specified, attempt to `require` it. # if typeof implementation is 'string' # if typeof registerLoader.dynamicLoad is 'function' # registerLoader.dynamicLoad name, implementation, metadata, callback # return # return callback Error "Dynamic loading of #{implementation} for component #{name} not available on this platform." # # Attempt to create the component instance using the `getComponent` method. # if typeof implementation.getComponent is 'function' # instance = implementation.getComponent metadata # Attempt to create a component using a factory function. # else if typeof implementation is 'function' # instance = implementation metadata # else # callback new Error "Invalid type #{typeof(implementation)} for component #{name}." # return # # instance.componentName = name if typeof name is 'string' # callback null, instance */ public Component createComponent(string name, string component) { Type componentType; if (!ComponentCatalog.RequestComponentsByQualifiedName().TryGetValue(name, out componentType)) { throw new Exception("TODO"); } Component instance = (Component)Activator.CreateInstance(componentType); instance.componentName = name; return(instance); }
public void LoadGraphFile() { Dictionary <string, Type> ComponentsByQualifiedName = ComponentCatalog.RequestComponentsByQualifiedName(); // Populate graph with nodes, edges and default vaules JSONGraphFileReader reader = new JSONGraphFileReader(GraphFile.text); JSONGraphFileReader.RawNode rawNodeData; while (reader.NextNode(out rawNodeData)) { Type componentType; if (!ComponentsByQualifiedName.TryGetValue(rawNodeData.QualifiedComponentName, out componentType)) { throw new Exception("No component available with name: " + rawNodeData.QualifiedComponentName); } Component c = AddNode(rawNodeData.Name, componentType); c.MetadataPosition = rawNodeData.metadataPosition; } JSONGraphFileReader.RawEdge rawEdgeData; while (reader.NextEdge(out rawEdgeData)) { AddEdge(rawEdgeData.srcProcess, rawEdgeData.srcPort, rawEdgeData.tgtProcess, rawEdgeData.tgtPort); } JSONGraphFileReader.RawDefaultValue rawDefaultValueData; while (reader.NextDefaultValue(out rawDefaultValueData)) { object treatedData = DataTreatment.TreatData(rawDefaultValueData.Data, this); if (treatedData == null) { continue; } AddDefaultValue(treatedData, rawDefaultValueData.tgtProcess, rawDefaultValueData.tgtPort); } }