public object CreateInstance(Type @class, IConstructorParameters constructorParameters) { ConstructorInfo[] constructorInfos = ConstructorInfoListGenerator.GenerateList(@class); IEnumerable <IConstructor> constructors = ConstructorListGenerator.GenerateList(constructorInfos); IConstructor constructor = ConstructorFinder.FindBy(constructors, constructorParameters); IEnumerable <IParameter> parameters = ParametersGenerator.GenerateParameters(constructor, constructorParameters); object[] values = ParametersValuesExtractor.ExtractValues(parameters); object instance = ConstructorInvoker.InvokeConstructor(constructor, values); return(instance); }
public IConstructor ProvideConstructor(IService service) { if (HasConstructorParametersChecker.Check(service)) { ConstructorInfo[] constructorInfos = InfoListGenerator.GenerateList(service.Registration.TargetType); IEnumerable <IConstructor> constructors = ListGenerator.GenerateList(constructorInfos); IConstructor constructor = ConstructorFinder.FindBy(constructors, service.Registration.RegistrationFlags.SelectValueOrNull <IConstructorParameters>(RegistrationFlagConstants.ConstructorParameters)); return(constructor); } else { return(ConstructorProvider.ProvideConstructor(service)); } }