public object CreateInstance(ServiceFlags flags, Type @class, IReadOnlyContainer container) { IConstructor constructor = ConstructorProvider.ProvideConstructor(@class); IEnumerable <IParameter> parameters = ParametersGenerator.GenerateParameters(constructor, flags, container); object[] values = ParametersValuesExtractor.ExtractValues(parameters); object instance = ConstructorInvoker.InvokeConstructor(constructor, values); return(instance); }
public object GenerateInstance(IService service, IReadOnlyContainer container) { if (HasServiceFactoryChecker.Check(service)) { IFactory factory = FactoryProvider.ProvideFactory(service); return(FactoryInstanceCreator.CreateInstance(factory, service, container)); } IConstructor constructor = ServiceConstructorProvider.ProvideConstructor(service); IEnumerable <IParameter> parameters = ConstructorParametersGenerator.GenerateParameters(constructor, service, container); object[] parametersValues = ParametersValuesExtractor.ExtractValues(parameters); return(ConstructorInvoker.InvokeConstructor(constructor, parametersValues)); }
public object BuildObject() { object[] arguments = _argumentBuilder.BuildArguments(); return(_constructor.InvokeConstructor(arguments)); }