private object CreateInstance(RegistrationModel model, object[] arguments = null) { object returnedObj = null; Type typeToCreate = model.ObjectType; if (model.RegType == REG_TYPE.TRANSIENT) { returnedObj = AddTransientInstance.GetInstance().GetNewObject(typeToCreate, arguments); } else if (model.RegType == REG_TYPE.SINGLETON) { returnedObj = AddSingletonInstance.GetInstance().GetSingleton(typeToCreate, arguments); } return(returnedObj); }
public object GetSingleton(Type t, object[] arguments = null) { object obj = null; try { if (objectPool.ContainsKey(t.Name) == false) { obj = AddTransientInstance.GetInstance().GetNewObject(t, arguments); objectPool.Add(t.Name, obj); } else { obj = objectPool[t.Name]; } } catch { // log it maybe } return(obj); }
static AddTransientInstance() { instance = new AddTransientInstance(); }