private object CreateObjectBasedOnExtension(NamedObjectSave objectToLoad, IElement elementSave, Layer layerToPutOn, PositionedObjectList <ElementRuntime> listToPopulate, string extension) { object returnObject = null; switch (extension) { case "scnx": returnObject = NamedObjectManager.LoadObjectForNos <Scene>(objectToLoad, elementSave, layerToPutOn, listToPopulate, this); break; case "shcx": returnObject = NamedObjectManager.LoadObjectForNos <ShapeCollection>(objectToLoad, elementSave, layerToPutOn, listToPopulate, this); break; case "nntx": //returnObject = NamedObjectManager.LoadNodeNetworkObject(objectToLoad, elementSave, layerToPutOn, listToPopulate, entireFileOnly); break; case "emix": returnObject = NamedObjectManager.LoadObjectForNos <EmitterList>(objectToLoad, elementSave, layerToPutOn, listToPopulate, this); break; case "splx": returnObject = NamedObjectManager.LoadObjectForNos <SplineList>(objectToLoad, elementSave, layerToPutOn, listToPopulate, this); break; } return(returnObject); }
private LoadedFile CreateObjectBasedOnExtension(NamedObjectSave objectToLoad, IElement elementSave, Layer layerToPutOn, PositionedObjectList <ElementRuntime> listToPopulate, string extension) { LoadedFile returnObject = null; if (!string.IsNullOrEmpty(objectToLoad.SourceFile)) { returnObject = NamedObjectManager.LoadObjectForNos(objectToLoad, elementSave, layerToPutOn, listToPopulate, this); //ReferencedFileSave rfs = elementSave.GetReferencedFileSaveRecursively( // objectToLoad.SourceFile); //if(rfs != null) //{ // returnObject = LoadReferencedFileSave(rfs, true, elementSave); //} } //switch (extension) //{ // case "scnx": // returnObject = NamedObjectManager.LoadObjectForNos<Scene>(objectToLoad, elementSave, layerToPutOn, listToPopulate, this); // break; // case "shcx": // returnObject = NamedObjectManager.LoadObjectForNos<ShapeCollection>(objectToLoad, elementSave, layerToPutOn, listToPopulate, this); // break; // case "nntx": // //returnObject = NamedObjectManager.LoadNodeNetworkObject(objectToLoad, elementSave, layerToPutOn, listToPopulate, entireFileOnly); // break; // case "emix": // returnObject = NamedObjectManager.LoadObjectForNos<EmitterList>(objectToLoad, elementSave, layerToPutOn, listToPopulate, this); // break; // case "splx": // returnObject = NamedObjectManager.LoadObjectForNos<SplineList>(objectToLoad, elementSave, layerToPutOn, listToPopulate, this); // break; // default: // // todo - loop through the custom object creators here: // break; //} return(returnObject); }
public static void Start(TreeNode <string> roseConfig) { Logger.Info("Rose.Engine version {0}", Settings.EngineVersion.ToString(1)); Logger.Info("{0} version {1}", Framework.ExecutingAssembly.GetName().Name, Framework.ExecutingVersion.ToString(3)); Logger.Info(""); Config = roseConfig.DeepClone(); var workerThreadCount = Config.GetValue("engine/workerThreadCount", "4").ToInt32(); if (workerThreadCount < 1 || workerThreadCount > 8) { throw new AegisException(RoseResult.InvalidArgument, "The range of 'workerThreadCount' is from 1 to 8."); } SpinWorker.WorkerThreadCount = workerThreadCount; Logger.Info("StorageEngine initializing..."); StorageEngine.Initialize(Config.GetNode("engine/storage")); lock (_listStarter) { _listStarter.Clear(); // Preprocessor { var assemblyName = Config.GetValue("services/preprocessor/assembly", null); Assembly assembly; if (assemblyName == null || Path.GetFileName(Framework.ExecutingAssembly.Location).Equals(assemblyName, StringComparison.OrdinalIgnoreCase)) { assembly = Framework.ExecutingAssembly; } else { assembly = LoadAssembly(assemblyName); } var handlerName = Config.GetValue("services/preprocessor/handler", null); if (handlerName != null) { Preprocessor = assembly.CreateInstance(handlerName) as IRosePreprocessor; if (Preprocessor == null) { throw new AegisException(RoseResult.InvalidHandler, "There is no '{0}' class or '{0}' is not derive from {1}.", handlerName, nameof(IRosePreprocessor)); } } } // Named objects var propNamedObjects = Config.TryGetNode("services/globalObjects"); if (propNamedObjects != null) { foreach (var target in propNamedObjects.Childs) { var assemblyName = target.GetValue("assembly"); var targetObject = target.GetValue("targetObject"); var objectName = target.GetValue("objectName"); var data = target.GetNode("data"); Assembly assembly; if (assemblyName == null || assemblyName == "") { assembly = Framework.ExecutingAssembly; } else { assembly = LoadAssembly(assemblyName); } var handlerInstance = assembly.CreateInstance(targetObject, false, BindingFlags.NonPublic | BindingFlags.Instance, null, null, null, null) as GlobalObjectBase; if (handlerInstance == null) { throw new AegisException(RoseResult.InvalidHandler, "There is no '{0}' class or '{0}' is not derive from {1}.", targetObject, nameof(IRosePreprocessor)); } handlerInstance.Name = objectName; handlerInstance.Data = data.DeepClone(); NamedObjectManager.Add(objectName, handlerInstance); handlerInstance.Initialize(); } } Logger.Info(""); Logger.Info("Registering network handlers..."); // Http Network foreach (var httpHandler in Config.GetNode("engine").Childs.Where(v => v.Name == "httpHandlers")) { var handlers = new List <Tuple <string, RequestHandler> >(); var starter = new Starter(); _listStarter.Add(starter); // 처리기 등록 foreach (var targetHandler in httpHandler.Childs.Where(v => v.Value == null)) { var handlerName = targetHandler.GetValue("handler"); var assemblyName = targetHandler.GetValue("assembly"); var route = targetHandler.GetValue("route"); Assembly assembly; if (assemblyName == null || Path.GetFileName(Framework.ExecutingAssembly.Location).Equals(assemblyName, StringComparison.OrdinalIgnoreCase)) { assembly = Framework.ExecutingAssembly; } else { assembly = LoadAssembly(assemblyName); Logger.Info("Routing on {0}", route); } var handlerInstance = assembly.CreateInstance(handlerName) as RequestHandler; if (handlerInstance == null) { throw new AegisException(RoseResult.InvalidHandler, "There is no '{0}' class or '{0}' is not derive from {1}.", handlerName, nameof(RequestHandler)); } handlerInstance.Config = targetHandler.DeepClone(); handlers.Add(new Tuple <string, RequestHandler>(route, handlerInstance)); Logger.Info("+ {0}", handlerName); } Logger.Info(""); var prefix = httpHandler.GetValue("prefix"); starter.StartHttpNetwork(prefix, handlers); } } }