public object GetSingleton(Type t, object[] arguments = null) { object obj = null; try { if (objectPool.ContainsKey(t.Name) == false) { obj = InstanceCreationService.GetInstance().GetNewObject(t, arguments); objectPool.Add(t.Name, obj); } else { obj = objectPool[t.Name]; } } catch { } return(obj); }
private object CreateInstance(RegistrationModel model, object[] arguments = null) { object returnedObj = null; Type typeToCreate = model.ObjectType; returnedObj = model.Flag ? SingletonCreationService.GetInstance().GetSingleton(typeToCreate, arguments): InstanceCreationService.GetInstance().GetNewObject(typeToCreate, arguments); SetterInject(typeToCreate, returnedObj); return(returnedObj); }
static InstanceCreationService() { instance = new InstanceCreationService(); }