private object GetInstance(RegisteredObject registeredObject, params object[] parameters) { if (registeredObject.Instance == null || registeredObject.LifeCycle == LifeCycle.Transient) { registeredObject.CreateInstance(parameters); } return(registeredObject.Instance); }
private object GetInstance(RegisteredObject registeredObject) { if (registeredObject.Instance == null || registeredObject.LifeCycle == LifeCycle.Transient) { Type implementation = registeredObject.ConcreteType; ConstructorInfo constructor = implementation.GetConstructors()[0]; ParameterInfo[] constructorParameters = constructor.GetParameters(); int paramsLength = constructorParameters.Length; object[] parameters = new object[paramsLength]; if (paramsLength > 0) { for (int i = 0; i < paramsLength; i++) { ParameterInfo parameterInfo = constructorParameters[i]; parameters[i] = Resolve(parameterInfo.ParameterType); } } registeredObject.CreateInstance(parameters); } return(registeredObject.Instance); }