protected override void Arrange()
        {
            updatableConfigurationSource = new ConfigurationSourceUpdatable();

            connectionStringsSection = new ConnectionStringsSection();
            connectionStringsSection.ConnectionStrings.Add(
                new ConnectionStringSettings
            {
                Name             = "default connection",
                ConnectionString = "connection string",
                ProviderName     = "System.Data.OracleClient"
            });

            connectionStringsSection.ConnectionStrings.Add(
                new ConnectionStringSettings
            {
                Name             = "other connection",
                ConnectionString = "connection string",
                ProviderName     = "System.Data.SqlClient"
            });

            databaseSettings = new DatabaseSettings {
                DefaultDatabase = "default connection"
            };

            updatableConfigurationSource.Add("connectionStrings", connectionStringsSection);
            updatableConfigurationSource.Add(DatabaseSettings.SectionName, databaseSettings);

            container             = new UnityContainer();
            containerConfigurator = new UnityContainerConfigurator(container);
            EnterpriseLibraryContainer.ConfigureContainer(containerConfigurator, updatableConfigurationSource);
        }
        private void ConfigureExceptionHandling()
        {
            var configurationSource = new DictionaryConfigurationSource();
            var builder             = new ConfigurationSourceBuilder();

            builder
            .ConfigureExceptionHandling()
            .GivenPolicyWithName(ValidationPolicy)
            .ForExceptionType <DeleteConstraintException>()
            .HandleCustom <BusinessValidationHandler>()
            .ThenThrowNewException()
            .ForExceptionType <BusinessValidationException>()
            .ThenNotifyRethrow()
            .ForExceptionType <BusinessException>()
            .HandleCustom <BusinessValidationHandler>()
            .ThenThrowNewException()
            .GivenPolicyWithName(DefaultPolicy)
            .ForExceptionType <Exception>()
            .LogToCategory("General")
            .WithSeverity(TraceEventType.Critical)
            .UsingExceptionFormatter <TextExceptionFormatter>()
            .WrapWith <Exception>()
            .UsingMessage("An error has occurred while processing request. Please contact your administrator for more information. [Error ID: {handlingInstanceID}]")
            .ThenThrowNewException();
            builder.UpdateConfigurationWithReplace(configurationSource);

            var configurator = new UnityContainerConfigurator(this.Container);

            EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource);
        }
Пример #3
0
        public void TestGetExceptionManagerFromServiceLocator()
        {
            // Create the container
            var container = new UnityContainer();

            // Configurator will read Enterprise Library configuration
            // and set up the container
            var configurator = new UnityContainerConfigurator(container);

            // Configuration source holds the new configuration we want to use
            // load this in your own code
            var configSource = new FileConfigurationSource("EntLib.config.xml");

            // Configure the container
            EnterpriseLibraryContainer.CreateDefaultContainer(configSource);

            // Wrap in ServiceLocator
            var locator = new UnityServiceLocator(container);

            // And set Enterprise Library to use it
            EnterpriseLibraryContainer.Current = locator;

            var exceptionManager = EnterpriseLibraryContainer.Current.GetInstance <ExceptionManager>();

            Assert.NotNull(exceptionManager);
        }
Пример #4
0
        private void ConfigureLogging()
        {
            var          configurationSource = new DictionaryConfigurationSource();
            var          builder             = new ConfigurationSourceBuilder();
            const string DefaultListenerName = "Default";

            builder.ConfigureLogging()
            .WithOptions
            .DoNotRevertImpersonation()
            .SpecialSources
            .LoggingErrorsAndWarningsCategory
            .SendTo.SharedListenerNamed(DefaultListenerName)
            .SpecialSources
            .UnprocessedCategory
            .SendTo.SharedListenerNamed(DefaultListenerName)
            .SpecialSources
            .AllEventsCategory
            .SendTo.SharedListenerNamed(DefaultListenerName)
            .LogToCategoryNamed("General")
            .WithOptions.SetAsDefaultCategory()
            .SendTo.SharedListenerNamed(DefaultListenerName);
            builder.UpdateConfigurationWithReplace(configurationSource);

            var configurator = new UnityContainerConfigurator(this.Container);

            EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource);

            this.Container.RegisterType <TraceListener, CommonLoggingEntlibTraceListener>(
                DefaultListenerName,
                new ContainerControlledLifetimeManager(),
                new InjectionFactory(this.CreateListener));
        }
Пример #5
0
        // http://www.nikosbaxevanis.com/bonus-bits/2011/08/following-the-composition-root-pattern-with-enterprise-library.html
        public static void ForEnterpriseLibrary(UnityContainer container)
        {
            var configurator = new UnityContainerConfigurator(container);
            var configSource = ConfigurationSourceFactory.Create();

            EnterpriseLibraryContainer.ConfigureContainer(configurator, configSource);
        }
Пример #6
0
        public void CreateLogger_WithConfiguredLogWriter_LogEntryIsForwardedToConfiguredLogWriter()
        {
            /* Create a mocked logwriter */
            LogWriter mockedLogWriter = MockRepository.GenerateMock <LogWriter>();

            /* Build up the EnterpriseLibraryContainer using Unity for the IoC */
            IUnityContainer container = new UnityContainer();

            container.RegisterInstance <LogWriter>("logwriter", mockedLogWriter); /* Any name will do */

            UnityContainerConfigurator configurator = new UnityContainerConfigurator(container);
            IConfigurationSource       configSource = new DictionaryConfigurationSource();

            EnterpriseLibraryContainer.ConfigureContainer(configurator, configSource);
            IServiceLocator locator = new UnityServiceLocator(container);

            EnterpriseLibraryContainer.Current = locator;

            /* Call the test subject */
            Logger result = LogManager.CreateLogger();

            /* Make sure the returned logger is not null... */
            Assert.IsNotNull(result);

            /* ...and that the returned logger is working with the configured LogWriter */
            LogEntry entry = new LogEntry("message", "category", 1, 1000, System.Diagnostics.TraceEventType.Information, "title", null);

            result.Log(entry);
            mockedLogWriter.AssertWasCalled(lw => lw.Write(Arg.Is(entry)));
        }
Пример #7
0
        /// <summary>
        /// Registers the type mappings with the Unity container.
        /// </summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>
        /// There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.
        /// </remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            UnityContainerConfigurator.ConfigureAzure(container);
            UnityContainerConfigurator.Configure(container, new PerRequestLifetimeManager());

            // Other configurations for interfaces that are internal to the current assembly
        }
    public void SetLogFilePath(string filePath)
    {
        ConfigurationFileMap objConfigPath = new ConfigurationFileMap();
        // App config file path.
        string appPath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

        objConfigPath.MachineConfigFilename = appPath;
        Configuration             entLibConfig                 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
        LoggingSettings           loggingSettings              = (LoggingSettings)entLibConfig.GetSection(LoggingSettings.SectionName);
        TraceListenerData         traceListenerData            = loggingSettings.TraceListeners.Get("Flat File Trace Listener");
        FlatFileTraceListenerData objFlatFileTraceListenerData = traceListenerData as FlatFileTraceListenerData;

        objFlatFileTraceListenerData.FileName = filePath;

        IUnityContainer container = new UnityContainer();

        container.AddNewExtension <EnterpriseLibraryCoreExtension>();
        // Configurator will read Enterprise Library configuration
        // and set up the container
        UnityContainerConfigurator configurator = new UnityContainerConfigurator(container);
        var loggingXmlConfigSource = new SerializableConfigurationSource();

        loggingXmlConfigSource.Add(LoggingSettings.SectionName, loggingSettings);
        // Configure the container with our own custom logging
        EnterpriseLibraryContainer.ConfigureContainer(configurator, loggingXmlConfigSource);
        // Wrap in ServiceLocator
        IServiceLocator locator = new UnityServiceLocator(container);

        // And set Enterprise Library to use it
        EnterpriseLibraryContainer.Current = locator;
    }
        public static UnityContainer Create()
        {
            var container = new UnityContainer();

            container.InstallCoreExtensions();

            // Configurator will read Enterprise Library configuration
            // and set up the container
            var configurator = new UnityContainerConfigurator(container);

            // Configuration source holds the new configuration we want to use
            // load this in your own code
            IConfigurationSource configSource = new SystemConfigurationSource(true);

            // Configure the container
            EnterpriseLibraryContainer.ConfigureContainer(configurator, configSource);

            // Self-register and set up service location
            container.RegisterInstance <IUnityContainer>(container);
            var locator = new UnityServiceLocator(container);

            ServiceLocator.SetLocatorProvider(() => locator);

            return(container);
        }
        public void Given()
        {
            container = new UnityContainer();
            var configurationSource     = new DictionaryConfigurationSource();
            ValidationSettings settings = new ValidationSettings();

            configurationSource.Add(ValidationSettings.SectionName, settings);
            ValidatedTypeReference typeReference = new ValidatedTypeReference(typeof(BaseTestDomainObject));

            settings.Types.Add(typeReference);
            typeReference.DefaultRuleset = "RuleA";
            ValidationRulesetData ruleData = new ValidationRulesetData("RuleA");

            typeReference.Rulesets.Add(ruleData);
            ValidatedPropertyReference propertyReference1 = new ValidatedPropertyReference("Property1");

            ruleData.Properties.Add(propertyReference1);
            MockValidatorData validator11 = new MockValidatorData("validator1", true);

            propertyReference1.Validators.Add(validator11);
            validator11.MessageTemplate = "message-from-config1-RuleA";
            MockValidatorData validator12 = new MockValidatorData("validator2", true);

            propertyReference1.Validators.Add(validator12);
            validator12.MessageTemplate = "message-from-config2-RuleA";
            MockValidatorData validator13 = new MockValidatorData("validator3", false);

            propertyReference1.Validators.Add(validator13);
            validator13.MessageTemplate = "message-from-config3-RuleA";

            var typeRegistrationProvider = new ValidationTypeRegistrationProvider();
            var configurator             = new UnityContainerConfigurator(container);

            configurator.RegisterAll(configurationSource, typeRegistrationProvider);
        }
        /// <summary>
        /// Create a new instance of <see cref="IServiceLocator"/> that has been configured
        /// with the information in the given <paramref name="configurationSource"/>.
        /// </summary>
        /// <param name="configurationSource"><see cref="IConfigurationSource"/> containing Enterprise Library
        /// configuration information.</param>
        /// <returns>The <see cref="IServiceLocator"/> object.</returns>
        public static IServiceLocator CreateDefaultContainer(IConfigurationSource configurationSource)
        {
            IUnityContainer container    = new UnityContainer();
            var             configurator = new UnityContainerConfigurator(container);

            ConfigureContainer(configurator, configurationSource);
            return(new UnityServiceLocator(container));
        }
Пример #12
0
        /// <summary>
        /// Adds to the <paramref name="container"/> the policy definitions represented in the configuration file.
        /// </summary>
        /// <param name="container">The container on which the injection policies must be configured.</param>
        /// <param name="configurationSource">The configuration source from which additional information
        /// can be retrieved, if necessary.</param>
        public void ConfigureContainer(IUnityContainer container, IConfigurationSource configurationSource)
        {
            Guard.ArgumentNotNull(container, "container");
            Guard.ArgumentNotNull(configurationSource, "configurationSource");

            UnityContainerConfigurator configurator = new UnityContainerConfigurator(container);

            configurator.RegisterAll(configurationSource, this);
        }
Пример #13
0
        public InterceptionStrategy()
        {
            IUnityContainer            container    = new UnityContainer();
            UnityContainerConfigurator configurator = new UnityContainerConfigurator(container);

            EnterpriseLibraryContainer.ConfigureContainer(configurator, ConfigurationSourceFactory.Create());
            this.UnityContainer     = container;
            this.InterceptionMember = new InstanceInterceptionPolicySettingInjectionMember(new TransparentProxyInterceptor());
        }
 /// <summary>
 /// Configures the Unity container to be able to resolve Enterprise Library
 /// objects.
 /// </summary>
 protected override void Initialize()
 {
     // Only need to do this once; do nothing if this extension has already
     // been added.
     if (Container.Configure <EnterpriseLibraryCoreExtension>() == this)
     {
         var configurator = new UnityContainerConfigurator(Container);
         EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource);
     }
 }
        public void Given()
        {
            container = new UnityContainer();
            var typeRegistrationProvider = new ValidationTypeRegistrationProvider();
            var configurator             = new UnityContainerConfigurator(container);

            configurator.RegisterAll(
                new DictionaryConfigurationSource(),
                typeRegistrationProvider);
        }
        public void Given()
        {
            configurationSource = new MockConfigSource();

            var mock = new Mock <ITypeRegistrationsProvider>();

            mock.Setup(p => p.GetRegistrations(It.IsAny <IConfigurationSource>()))
            .Returns(new TypeRegistration[0]);

            mockRegistrationsProvider = mock.Object;

            container    = new UnityContainer();
            configurator = new UnityContainerConfigurator(container);
            configurator.RegisterAll(configurationSource, mockRegistrationsProvider);
        }
Пример #17
0
        protected override void Arrange()
        {
            updatableConfigurationSource = new ConfigurationSourceUpdatable();

            ruleProvider      = new AuthorizationRuleProviderData();
            ruleProvider.Name = "ruleProvider";

            settings = new SecuritySettings();
            settings.AuthorizationProviders.Add(ruleProvider);

            updatableConfigurationSource.Add(SecuritySettings.SectionName, settings);

            container             = new UnityContainer();
            containerConfigurator = new UnityContainerConfigurator(container);
            EnterpriseLibraryContainer.ConfigureContainer(containerConfigurator, updatableConfigurationSource);
        }
Пример #18
0
        public static void ConfigureContainer(Action <IUnityContainer> action)
        {
            IUnityContainer container = new UnityContainer();

            if (action != null)
            {
                action(container);
            }

            IContainerConfigurator configurator = new UnityContainerConfigurator(container);

            EnterpriseLibraryContainer.ConfigureContainer(configurator, ConfigurationSourceFactory.Create());
            IServiceLocator locator = new UnityServiceLocator(container);

            EnterpriseLibraryContainer.Current = locator;
        }
        protected override void Arrange()
        {
            updatableConfigurationSource = new ConfigurationSourceUpdatable();

            exceptionPolicy1  = new ExceptionPolicyData("default");
            exceptionTypeData = new ExceptionTypeData("Exception", "System.Exception", PostHandlingAction.ThrowNewException);
            exceptionPolicy1.ExceptionTypes.Add(exceptionTypeData);

            ehabSettings = new ExceptionHandlingSettings();
            ehabSettings.ExceptionPolicies.Add(exceptionPolicy1);

            updatableConfigurationSource.Add(ExceptionHandlingSettings.SectionName, ehabSettings);

            container             = new UnityContainer();
            containerConfigurator = new UnityContainerConfigurator(container);
            EnterpriseLibraryContainer.ConfigureContainer(containerConfigurator, updatableConfigurationSource);
        }
        protected override void Arrange()
        {
            updatableConfigurationSource = new ConfigurationSourceUpdatable();
            cryptoSettings = new CryptographySettings();

            hashProvider = new HashAlgorithmProviderData("hash provider", typeof(MD5), true);
            cryptoSettings.HashProviders.Add(hashProvider);
            cryptoSettings.DefaultHashProviderName = hashProvider.Name;

            symmetricAlgorithmProvider = new CustomSymmetricCryptoProviderData("symm provider", typeof(MockCustomSymmetricProvider));
            cryptoSettings.SymmetricCryptoProviders.Add(symmetricAlgorithmProvider);
            cryptoSettings.DefaultSymmetricCryptoProviderName = symmetricAlgorithmProvider.Name;
            updatableConfigurationSource.Add(CryptographySettings.SectionName, cryptoSettings);

            container             = new UnityContainer();
            containerConfigurator = new UnityContainerConfigurator(container);
            EnterpriseLibraryContainer.ConfigureContainer(containerConfigurator, updatableConfigurationSource);
        }
        public void StartCacheProcesses()
        {
            sharedLock       = new object();
            callbackCount    = 0;
            callbackReason   = CacheItemRemovedReason.Unknown;
            exceptionMessage = "";

            var defaultProvider = TypeRegistrationsProvider.CreateDefaultProvider();

            var registrationProvider = new CompositeTypeRegistrationsProviderLocator(defaultProvider, new RaceConditionSimulatingExpirationTaskRegistrationProvider());

            IUnityContainer     container           = new UnityContainer();
            var                 configurator        = new UnityContainerConfigurator(container);
            UnityServiceLocator unityServiceLocator = new UnityServiceLocator(container);

            EnterpriseLibraryContainer.ConfigureContainer(registrationProvider, configurator, TestConfigurationSource.GenerateConfiguration());

            cacheManager = (CacheManager)unityServiceLocator.GetInstance <ICacheManager>("ShortInMemoryPersistence");
        }
        protected override void Initialize()
        {
            this.WellKnownITypeNameAutoRegistration <ContainerControlledLifetimeManager>(WellKnownAppParts.Manager);
            this.Container.RegisterType <IApplicationPrincipal, ThreadApplicationPrincipal>(new ContainerControlledLifetimeManager());

            var configurationSource = new DictionaryConfigurationSource();
            var builder             = new ConfigurationSourceBuilder();

            builder.ConfigureCryptography()
            .EncryptUsingHashAlgorithmProviderNamed(UserManager.HashInstance)
            .WithOptions
            .UsingHashAlgorithm <Zetetic.Security.Pbkdf2Hash>()
            /*.SetAsDefault()*/;     // do not want Pbkdf2Hash (low speed algorithm) to be default
            builder.UpdateConfigurationWithReplace(configurationSource);

            var configurator = new UnityContainerConfigurator(this.Container);

            EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource);
        }
Пример #23
0
        /// <summary>
        /// Load the known types of EntepriseLibrary into the UnityContainer. Optionally updates the Enterprise Library container with
        /// the wrapped container.
        /// </summary>
        /// <para>http://msdn.microsoft.com/en-us/library/ff664535(v=pandp.50).aspx</para>
        /// <param name="container"></param>
        /// <param name="setEntepriseLibraryToUseIt">whether or not update the Enterprise Library container</param>
        /// <returns>A IUnityContainer with the Enterprise Library types into its container</returns>
        public static IUnityContainer LoadEnterpriseLibraryTypes(this IUnityContainer container, bool setEntepriseLibraryToUseIt = false)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            var unityConfiguratorContainer = new UnityContainerConfigurator(container);
            var configurationSourceFactory = ConfigurationSourceFactory.Create();

            EnterpriseLibraryContainer.ConfigureContainer(unityConfiguratorContainer, configurationSourceFactory);

            if (setEntepriseLibraryToUseIt)
            {
                IServiceLocator locator = new UnityServiceLocator(container);
                EnterpriseLibraryContainer.Current = locator;
            }
            return(container);
        }
        private void ConfigureExceptionHandling()
        {
            var configurationSource = new DictionaryConfigurationSource();

            var builder = new ConfigurationSourceBuilder();

            builder.ConfigureExceptionHandling()
            .GivenPolicyWithName(DeletePolicy)
            .ForExceptionType <Exception>()
            .ThenNotifyRethrow()
            .ForExceptionType <NHibernate.Exceptions.ConstraintViolationException>()
            .WrapWith <DeleteConstraintException>()
            .UsingMessage("Cannot delete object.")
            .ThenThrowNewException();
            builder.UpdateConfigurationWithReplace(configurationSource);

            var configurator = new UnityContainerConfigurator(this.Container);

            EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource);
        }
        public static IUnityContainer GetUnityContainer()
        {
            if (m_unityContainer == null)
            {
                lock (m_locker)
                {
                    if (m_unityContainer == null)
                    {
                        m_unityContainer = new UnityContainer();

                        UnityContainerConfigurator configurator = new UnityContainerConfigurator(m_unityContainer);
                        EnterpriseLibraryContainer.ConfigureContainer(configurator, ConfigurationSourceFactory.Create());
                        m_unityContainer.AddNewExtension <InterceptionExtension>();

                        //If load mapping setting from config
                        //m_unityContainer.LoadConfiguration();
                    }
                }
            }

            return(m_unityContainer);
        }
Пример #26
0
        /// <summary>
        /// The config with enterprise library container.
        /// </summary>
        private static void ConfigWithEnterpriseLibraryContainer()
        {
            // Create the container
            IUnityContainer container = new UnityContainer();

            // Configurator will read Enterprise Library configuration
            // and set up the container
            var configurator = new UnityContainerConfigurator(container);

            // Configuration source holds the new configuration we want to use
            // load this in your own code
            IConfigurationSource configSource = ReadConfigSource();

            // Configure the container
            EnterpriseLibraryContainer.CreateDefaultContainer(configSource);

            // Wrap in ServiceLocator
            IServiceLocator locator = new UnityServiceLocator(container);

            // And set Enterprise Library to use it
            EnterpriseLibraryContainer.Current = locator;
        }
        /// <summary>
        /// The config with enterprise library container.
        /// </summary>
        private static void ConfigWithEnterpriseLibraryContainer()
        {
            // Create the container
            IUnityContainer container = new UnityContainer();

            // Configurator will read Enterprise Library configuration 
            // and set up the container
            var configurator = new UnityContainerConfigurator(container);

            // Configuration source holds the new configuration we want to use 
            // load this in your own code
            IConfigurationSource configSource = ReadConfigSource();

            // Configure the container
            EnterpriseLibraryContainer.CreateDefaultContainer(configSource);

            // Wrap in ServiceLocator
            IServiceLocator locator = new UnityServiceLocator(container);

            // And set Enterprise Library to use it
            EnterpriseLibraryContainer.Current = locator;
        }
Пример #28
0
        public void Setup()
        {
            configurationSource = new ConfigurationSourceUpdatable();
            cacheSettings       = new CacheManagerSettings();

            configurationSource.Add(CacheManagerSettings.SectionName, cacheSettings);

            cacheStorageData = new CacheStorageData("Null Storage", typeof(NullBackingStore));
            cacheManagerData = new CacheManagerData("Default Cache Manager", 10, 10, 10, cacheStorageData.Name);

            CacheManagerSettings settings = new CacheManagerSettings();

            cacheSettings.CacheManagers.Add(cacheManagerData);
            cacheSettings.BackingStores.Add(cacheStorageData);
            cacheSettings.DefaultCacheManager = cacheManagerData.Name;

            UnityContainer container = new UnityContainer();

            configurator   = new UnityContainerConfigurator(container);
            serviceLcoator = new UnityServiceLocator(container);
            EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource);
        }
Пример #29
0
        protected override void Arrange()
        {
            updatableConfigurationSource = new ConfigurationSourceUpdatable();

            matchingRuleData1      = new MemberNameMatchingRuleData("Member()");
            matchingRuleData1.Name = "matchingRuleData1";

            callHandler1 = new CustomCallHandlerData("callHandler1", typeof(GlobalCountCallHandler));

            policy1      = new PolicyData();
            policy1.Name = "policy1";

            policy1.MatchingRules.Add(matchingRuleData1);
            policy1.Handlers.Add(callHandler1);

            settings = new PolicyInjectionSettings();
            settings.Policies.Add(policy1);

            updatableConfigurationSource.Add(PolicyInjectionSettings.SectionName, settings);

            container             = new UnityContainer();
            containerConfigurator = new UnityContainerConfigurator(container);
            EnterpriseLibraryContainer.ConfigureContainer(containerConfigurator, updatableConfigurationSource);
        }
        private void ConfigureExceptionHandling()
        {
            var configurationSource = new DictionaryConfigurationSource();
            var builder             = new ConfigurationSourceBuilder();

            builder
            .ConfigureExceptionHandling()
            .GivenPolicyWithName(DefaultPolicy)
            .ForExceptionType <DeleteConstraintException>()
            .HandleCustom <HttpErrorExceptionHandler>()
            .ThenThrowNewException()
            .ForExceptionType <BusinessValidationException>()
            .HandleCustom <BusinessValidationExceptionHandler>()
            .ThenThrowNewException()
            .ForExceptionType <BusinessException>()
            .HandleCustom <HttpErrorExceptionHandler>()
            .ThenThrowNewException()
            .ForExceptionType <Exception>()
            .LogToCategory("General")
            .WithSeverity(TraceEventType.Critical)
            .UsingExceptionFormatter <TextExceptionFormatter>()
            .HandleCustom(
                typeof(HttpErrorExceptionHandler),
                new NameValueCollection
            {
                { HttpErrorExceptionHandler.StatusCodeKey, HttpStatusCode.InternalServerError.ToString("G") },
                { HttpErrorExceptionHandler.MessageKey, "An error has occurred while consuming this service. Please contact your administrator for more information." },
                { HttpErrorExceptionHandler.AppendHandlingIdKey, bool.TrueString }
            })
            .ThenThrowNewException();
            builder.UpdateConfigurationWithReplace(configurationSource);

            var configurator = new UnityContainerConfigurator(this.Container);

            EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource);
        }
Пример #31
0
 protected override void Act()
 {
     var configurator = new UnityContainerConfigurator(this.container);
 }