public IBusinessConfig <IUnityContainer, TBusinessProcess> ConfigureOperationParameter <TService, TImplementation>(string operationName, Func <IUnityContainer, TImplementation> getImpl, bool updateIfExist = false) where TImplementation : TService { Guard.AssertNotNull(getImpl, ""); var config = new UnityBusinessOperationConfig(); config.Register(c => c.RegisterType(typeof(TService), typeof(TImplementation), operationName, new InjectionFactory((UnCon, tp, s) => getImpl(UnCon)))); if (updateIfExist) { BusinessOperationConfigs.Update(operationName, config); } else { BusinessOperationConfigs.New(operationName, config); } return(this); }
public IBusinessConfig <IUnityContainer, TBusinessProcess> ConfigureOperationParameter <TService, TImplementation>(bool updateIfExist = false) where TImplementation : TService { Guard.Against <ArgumentNullException>(Container == null, "Ошибка определения конфигурации Operation: не определен Unity контейнер"); string operationName = typeof(TService).FullName; var config = new UnityBusinessOperationConfig(); config.Register(c => c.RegisterType <TService, TImplementation>()); if (updateIfExist) { BusinessOperationConfigs.Update(operationName, config); } else { BusinessOperationConfigs.New(operationName, config); } return(this); }
public IBusinessConfig <IUnityContainer, TBusinessProcess> ConfigureSingletonParameter <TService, TImplementation>(string operationName, ConstructorParameterCollection constructorArguments, bool updateIfExist = false) where TImplementation : TService { Guard.Against <ArgumentNullException>(Container == null, "Ошибка определения конфигурации Operation: не определен Unity контейнер"); //Guard.Against<ArgumentNullException>(implementation==null, "Ошибка определения конфигурации Operation: не определен объект implementation"); var config = new UnityBusinessOperationConfig(); config.Register(c => c.RegisterType <TService, TImplementation>(operationName, new ContainerControlledLifetimeManager(), new SmartConstructor(constructorArguments))); if (updateIfExist) { BusinessOperationConfigs.Update(operationName, config); } else { BusinessOperationConfigs.New(operationName, config); } return(this); }
public IBusinessConfig <IUnityContainer, TBusinessProcess> ConfigureOperation <TService, TImplementation>(string operationName, bool updateIfExist = false) where TImplementation : TService { Guard.Against <ArgumentNullException>(Container == null, "Ошибка определения конфигурации Operation: не определен Unity контейнер"); Guard.Against <ArgumentNullException>(string.IsNullOrEmpty(operationName), "Ошибка определения конфигурации Operation: не определено название стратегии"); var config = new UnityBusinessOperationConfig(); config.Register(c => c.RegisterType <TService, TImplementation>(operationName)); if (updateIfExist) { BusinessOperationConfigs.Update(operationName, config); } else { BusinessOperationConfigs.New(operationName, config); } return(this); }
public IBusinessConfig <IUnityContainer, TBusinessProcess> ConfigureOperationParameter <TService, TImplementation>(ConstructorParameterCollection constructorArguments, bool updateIfExist = false) where TImplementation : TService { Guard.Against <ArgumentNullException>(Container == null, "Ошибка определения конфигурации Operation: не определен Unity контейнер"); Guard.Against <ArgumentNullException>(constructorArguments.IsNullOrEmpty(), "Ошибка определения конфигурации Operation: не определены аргументы конструктора"); string operationName = typeof(TService).FullName; var config = new UnityBusinessOperationConfig(); config.Register(c => c.RegisterType <TService, TImplementation>(new SmartConstructor(constructorArguments))); if (updateIfExist) { BusinessOperationConfigs.Update(operationName, config); } else { BusinessOperationConfigs.New(operationName, config); } return(this); }
public IBusinessConfig <IUnityContainer, TBusinessProcess> ConfigureOperationGenericParameter(string parameterName, Type serviceType, Type implementationType, bool updateIfExist = false) { Guard.AssertNotEmpty(parameterName, "Не определено имя параметра"); Guard.Against <ArgumentNullException>(Container == null, "Ошибка определения конфигурации Operation: не определен Unity контейнер"); //Guard.Against<ArgumentNullException>(string.IsNullOrEmpty(operationName), "Ошибка определения конфигурации Operation: не определено название стратегии"); var config = new UnityBusinessOperationConfig(); config.Register(c => c.RegisterType(serviceType, implementationType, parameterName, new TransientLifetimeManager())); if (updateIfExist) { BusinessOperationConfigs.Update(parameterName, config); } else { BusinessOperationConfigs.New(parameterName, config); } return(this); }