public void BuildConfiguration()
        {
            Guard.Against <ArgumentNullException>(Container == null, "Ошибка построения конфигурации: не определен Unity - контейнер");
            Guard.Against <ArgumentNullException>(NCommonConfigActions != null && NCommonConfigGets != null, "Ошибка построения конфигурации: определено две взаимоисключающие конфигурации NCommon");

            try
            {
                if (NCommonConfigActions != null)
                {
                    var adapter = new UnityContainerAdapter(Container);
                    NCommonConfigActions(Configure.Using(adapter));
                }
                else if (NCommonConfigGets != null)
                {
                    NCommonConfigGets(Container);
                }

                if (!BusinessOperationConfigs.IsNullOrEmpty())
                {
                    BusinessOperationConfigs.ForEach(config => config.Value.Confugure(Container));
                }

                if (ProcessConfig != null)
                {
                    ProcessConfig.Confugure(Container);
                }

                //Validate
                var validStr = Container.GetMappingAsString();
            }
            catch (Exception e)
            {
                throw;
            }
        }
        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> ConfigureOperation(BusinessOperationConfigCollection <IUnityContainer> configs, bool updateIfExist)
        {
            Guard.Against <ArgumentNullException>(Container == null, "Ошибка определения конфигурации Operation: не определен Unity контейнер");

            if (configs.IsNullOrEmpty())
            {
                return(this);
            }

            if (updateIfExist)
            {
                configs.ForEach(config => BusinessOperationConfigs.Update(config.Key, config.Value));
            }
            else
            {
                configs.ForEach(config => BusinessOperationConfigs.New(config.Key, config.Value));
            }

            return(this);
        }
        public IBusinessConfig <IUnityContainer, TBusinessProcess> ConfigureOperation <T>(string operationName, Action <T> actions, bool updateIfExist) where T : IBusinessOperationConfig <IUnityContainer>, new()
        {
            Guard.Against <ArgumentNullException>(Container == null, "Ошибка определения конфигурации Operation: не определен Unity контейнер");
            Guard.Against <ArgumentNullException>(string.IsNullOrEmpty(operationName), "Ошибка определения конфигурации Operation: не определено название стратегии");
            Guard.Against <ArgumentNullException>(actions == null, "Ошибка определения конфигурации Operation: не определены действия конфигурации");

            var config = new T();

            actions(config);
            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);
        }