public string ModuleCommand(IList <string> arguments) { int reactorId = int.Parse(arguments[0]); string moduleType = arguments[1]; int additionalParameter = int.Parse(arguments[2]); IModule module = moduleFactory.CreateModule(moduleType, currentId++, additionalParameter); this.modules.Add(module.Id, module); this.identifiableObjects.Add(module.Id, module); IReactor reactor = this.reactors[reactorId]; if (module is IEnergyModule energyModule) { reactor.AddEnergyModule(energyModule); } else if (module is IAbsorbingModule absorbingModule) { reactor.AddAbsorbingModule(absorbingModule); } string result = string.Format(Constants.ModuleCreateMessage, moduleType, module.Id, reactorId); return(result); }
Module CreateModule(string jsonString, IModuleFactory moduleFactory) { JsonObject jo = (JsonObject)JsonValue.Parse(jsonString); string type = GetValueFromObjectOrDie(jo, ModuleType); int gates = GetValueFromObjectOrDie(jo, ModuleGates); return(moduleFactory.CreateModule(type, jsonString)); }
public T GetModule <T>() where T : class { ModuleSearchKeys moduleSearchKeys = ModuleSearchKeys.Allocate <T>(); object module = moduleCache.GetModule(moduleSearchKeys); if (module == null) { module = moduleFactory.CreateModule(moduleSearchKeys); moduleCache.AddModule(moduleSearchKeys, module); } moduleSearchKeys.Release2Pool(); return(module as T); }
public T GetModule <T>() where T : class { // 申请对象 var moduleSearchKeys = ModuleSearchKeys.Allocate <T>(); var module = mCache.GetModule(moduleSearchKeys); if (module == null) { module = mFactory.CreateModule(moduleSearchKeys); mCache.AddModule(moduleSearchKeys, module); } // 回收对象 moduleSearchKeys.Release2Pool(); return(module as T); }
protected override object CreateInstance() { _module = (MvcModule)_moduleFactory.CreateModule(ActionContext); return(_module); }