public async Task<EndpointConfiguration> GetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointConfiguration, IConfigurationSource configSource, Action<EndpointConfiguration> configurationBuilderCustomization)
        {
            var settings = runDescriptor.Settings;

            var types = endpointConfiguration.GetTypesScopedByTestClass();

            typesToInclude.AddRange(types);

            var builder = new EndpointConfiguration(endpointConfiguration.EndpointName);

            builder.TypesToIncludeInScan(typesToInclude);
            builder.CustomConfigurationSource(configSource);
            builder.EnableInstallers();

            builder.DisableFeature<TimeoutManager>();
            builder.Recoverability().Delayed(cfg => cfg.NumberOfRetries(0));
            builder.Recoverability().Immediate(cfg => cfg.NumberOfRetries(0));

            await builder.DefineTransport(settings, endpointConfiguration.EndpointName).ConfigureAwait(false);

            builder.DefineBuilder(settings);
            builder.RegisterComponentsAndInheritanceHierarchy(runDescriptor);

            Type serializerType;
            if (settings.TryGet("Serializer", out serializerType))
            {
                builder.UseSerialization((SerializationDefinition) Activator.CreateInstance(serializerType));
            }
            await builder.DefinePersistence(settings, endpointConfiguration.EndpointName).ConfigureAwait(false);

            builder.GetSettings().SetDefault("ScaleOut.UseSingleBrokerQueue", true);
            configurationBuilderCustomization(builder);

            return builder;
        }
 public string MapName(string name, IConfigurationSource configSource)
 {
     if (name != null)
         return name;
     else
         return new SecurityConfigurationView(configSource).GetDefaultAuthorizationProviderName();
 }
        public Configure GetConfiguration(RunDescriptor runDescriptor, EndpointConfiguration endpointConfiguration,
            IConfigurationSource configSource)
        {
            var settings = runDescriptor.Settings;

            var types = GetTypesToUse(endpointConfiguration);

            var transportToUse = settings.GetOrNull("Transport");

            SetupLogging(endpointConfiguration);

            Configure.Features.Enable<Sagas>();

            var config = Configure.With(types)
                                  .DefineEndpointName(endpointConfiguration.EndpointName)
                                  .DefineBuilder(settings.GetOrNull("Builder"))
                                  .CustomConfigurationSource(configSource)
                                  .DefineSerializer(settings.GetOrNull("Serializer"))
                                  .DefineTransport(transportToUse)
                                  .InMemorySagaPersister();

            if (transportToUse == null || transportToUse.Contains("Msmq") || transportToUse.Contains("SqlServer") ||
                transportToUse.Contains("RabbitMq"))
                config.UseInMemoryTimeoutPersister();

            if (transportToUse == null || transportToUse.Contains("Msmq") || transportToUse.Contains("SqlServer"))
                config.InMemorySubscriptionStorage();

            config.InMemorySagaPersister();

            return config.UnicastBus();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntLib5Factory"/> class.
 /// </summary>
 /// <param name="EntLib5ConfigurationSrc">The enterprise library 5.0 configuration source to load. Supercedes any configuration found in the Config file.</param>
 public EntLib5Factory(IConfigurationSource EntLib5ConfigurationSrc)
 {
     // replace any settings from App.Config with the ones in the provided config source
     var builder = new ConfigurationSourceBuilder();
     builder.UpdateConfigurationWithReplace(EntLib5ConfigurationSrc);
     EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(EntLib5ConfigurationSrc);
 }
        /// <summary>
        /// public for unittesting purposes.
        /// </summary>
        /// <param name="configurationSource"></param>
        /// <param name="reconfiguringEventSource"></param>
        /// <returns></returns>
        public static IEnumerable<ITypeRegistrationsProvider> CreateTypeRegistrationsProviderLocators(IConfigurationSource configurationSource, IContainerReconfiguringEventSource reconfiguringEventSource)
        {
            TypeRegistrationProvidersConfigurationSection section = configurationSource.GetSection(TypeRegistrationProvidersConfigurationSection.SectionName) as TypeRegistrationProvidersConfigurationSection;
            if (section == null)
            {
                section = new TypeRegistrationProvidersConfigurationSection();
            }

            foreach (TypeRegistrationProviderElement typeRegistrationProviderElement in section.TypeRegistrationProviders)
            {
                if (!string.IsNullOrEmpty(typeRegistrationProviderElement.SectionName) &&
                    !string.IsNullOrEmpty(typeRegistrationProviderElement.ProviderTypeName))
                {
                    throw new ConfigurationErrorsException(
                        string.Format("Type Registration Provider Settings '{0}' cannot declare both sectionName and providerType attributes",
                        typeRegistrationProviderElement.Name));
                }
                if (!string.IsNullOrEmpty(typeRegistrationProviderElement.SectionName))
                {
                    yield return new ConfigSectionLocator(typeRegistrationProviderElement.SectionName, reconfiguringEventSource);
                }
                else if (!string.IsNullOrEmpty(typeRegistrationProviderElement.ProviderTypeName))
                {
                    yield return new TypeLoadingLocator(typeRegistrationProviderElement.ProviderTypeName, reconfiguringEventSource);
                }
            }
        }
        public void SetUp()
        {
            DatabaseDriver.Bootstrap(true);

            container = DatabaseDriver.ContainerWithDatabase();
            source = container.GetInstance<IConfigurationSource>();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Builds an instance of the concrete subtype of <see cref="T:Microsoft.Practices.EnterpriseLibrary.Data.Database"/> 
        /// the receiver knows how to build, based on the provided connection string and any configuration information 
        /// that might be contained by the <paramref name="configurationSource"/>.
        /// </summary>
        /// <param name="name">The name for the new database instance.</param>
        /// <param name="connectionStringSettings">The connection string for the new database instance.</param>
        /// <param name="configurationSource">The source for any additional configuration information.</param>
        /// <returns>
        /// The new database instance.
        /// </returns>
        public Database Assemble(string name, ConnectionStringSettings connectionStringSettings,
                                 IConfigurationSource configurationSource) {
            if(IsDebugEnabled)
                log.Debug("EnterpriseLibrary용 OracleProvider 인스턴스를 빌드합니다... name=[{0}]", name);

            var settings = OracleConnectionSettings.GetSettings(configurationSource);

            if(settings != null) {
                var data = settings.OracleConnectionsData.Get(name);

                if(data != null) {
                    var packages = new IOraclePackage[data.Packages.Count];
                    var num = 0;

                    foreach(var package in data.Packages) {
                        packages[num++] = package;
                    }
                    return new OracleDatabase(connectionStringSettings.ConnectionString);
                }
            }

            if(IsDebugEnabled)
                log.Debug("OracleDatabase를 생성합니다. connectionString=[{0}]", connectionStringSettings.ConnectionString);

            return new OracleDatabase(connectionStringSettings.ConnectionString);
        }
Exemplo n.º 8
0
 public MessageProcessor(IMessageSource msgSource, IMessageMatcher matcher, ISubscriptionStore store, IConfigurationSource cfg)
 {
     LiveMessageSource = msgSource;
     MessageMatcher = matcher;
     SubscriptionStore = store;
     TaskDelay = cfg.Get<int>(this, DefaultDelayKey, DefaultDelay);
 }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigurationSource"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        public ConfigurationSource(IConfigurationSource source)
            : base(source)
        {
            if (source.Servers != null && source.Servers.Any())
            {
                this.Servers = source.Servers.Select(s => new ServerConfig(s)).ToArray();
            }

            if (source.ServerTypes != null && source.ServerTypes.Any())
            {
                this.ServerTypes = source.ServerTypes.Select(s => s.CopyPropertiesTo(new TypeProviderConfig())).ToArray();
            }

            if (source.ConnectionFilters != null && source.ConnectionFilters.Any())
            {
                this.ConnectionFilters = source.ConnectionFilters.Select(s => s.CopyPropertiesTo(new TypeProviderConfig())).ToArray();
            }

            if (source.LogFactories != null && source.LogFactories.Any())
            {
                this.LogFactories = source.LogFactories.Select(s => s.CopyPropertiesTo(new TypeProviderConfig())).ToArray();
            }

            if (source.ReceiveFilterFactories != null && source.ReceiveFilterFactories.Any())
            {
                this.ReceiveFilterFactories = source.ReceiveFilterFactories.Select(s => s.CopyPropertiesTo(new TypeProviderConfig())).ToArray();
            }

            if (source.CommandLoaders != null && source.CommandLoaders.Any())
            {
                this.CommandLoaders = source.CommandLoaders.Select(s => s.CopyPropertiesTo(new TypeProviderConfig())).ToArray();
            }
        }
Exemplo n.º 10
0
        public Task<EndpointConfiguration> GetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointConfiguration, IConfigurationSource configSource, Action<EndpointConfiguration> configurationBuilderCustomization)
        {
            var types = GetTypesScopedByTestClass(endpointConfiguration);

            typesToInclude.AddRange(types);

            var builder = new EndpointConfiguration(endpointConfiguration.EndpointName);

            builder.TypesToIncludeInScan(typesToInclude);
            builder.CustomConfigurationSource(configSource);
            builder.EnableInstallers();

            builder.DisableFeature<TimeoutManager>();
            builder.Recoverability()
                .Delayed(delayed => delayed.NumberOfRetries(0))
                .Immediate(immediate => immediate.NumberOfRetries(0));

            builder.RegisterComponents(r => { RegisterInheritanceHierarchyOfContextOnContainer(runDescriptor, r); });

            builder.UsePersistence<InMemoryPersistence>();

            configurationBuilderCustomization(builder);

            return Task.FromResult(builder);
        }
        protected override void Arrange()
        {
            base.Arrange();

            Source = new DictionaryConfigurationSource();

            ConfigurationSourceBuilder sourceBuilder = new ConfigurationSourceBuilder();
            sourceBuilder.ConfigureExceptionHandling()
                .GivenPolicyWithName("SomePolicy")
                    .ForExceptionType<Exception>()
                        .ReplaceWith<ApplicationException>()
                        .WrapWith<ArgumentException>()
                        .ThenThrowNewException()
                    .ForExceptionType<ArithmeticException>()
                        .LogToCategory("ArithmicExceptions")
                        .ThenDoNothing()
                .GivenPolicyWithName("Global Policy")
                    .ForExceptionType<Exception>()
                        .ReplaceWith<ApplicationException>()
                        .UsingMessage("replacement message")
                        .WrapWith<Exception>()
                        .ThenNotifyRethrow()
                    .ForExceptionType<InvalidCastException>()
                        .WrapWith<ApplicationException>()
                        .WrapWith<Exception>()
                        .UsingMessage("yes, thats a known bug")
                        .ThenThrowNewException();

            sourceBuilder.UpdateConfigurationWithReplace(Source);

            Section = (ExceptionHandlingSettings)Source.GetSection(ExceptionHandlingSettings.SectionName);
        }
Exemplo n.º 12
0
        public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            MockTraceListenerClient createdObject = new MockTraceListenerClient();
            createdObject.traceListener = TraceListenerCustomFactory.Instance.Create(context, name, configurationSource, reflectionCache);

            return createdObject;
        }
        /// <summary>
        /// Consume the set of <see cref="TypeRegistration"/> objects and
        /// configure the associated container.
        /// </summary>
        /// <param name="configurationSource">Configuration source to read registrations from.</param>
        /// <param name="rootProvider"><see cref="ITypeRegistrationsProvider"/> that knows how to
        /// read the <paramref name="configurationSource"/> and return all relevant type registrations.</param>
        public void RegisterAll(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider)
        {
            RegisterAllCore(configurationSource, rootProvider);

            this.configurationSource = configurationSource;
            configurationSource.SourceChanged += OnConfigurationSourceChanged;
        }
Exemplo n.º 14
0
        public string MapName(string name, IConfigurationSource configurationSource)
        {
            if (name != null)
                return name;

            return new SecurityConfigurationView(configurationSource).GetDefaultSecurityCacheProviderName();
        }
Exemplo n.º 15
0
        private static CachingInstrumentationProvider CreateInstrumentationProvider(string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            CachingInstrumentationProvider instrumentationProvider = new CachingInstrumentationProvider();
            new InstrumentationAttachmentStrategy().AttachInstrumentation(name, instrumentationProvider, configurationSource, reflectionCache);

            return instrumentationProvider;
        }
        public async Task<EndpointConfiguration> GetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointConfiguration, IConfigurationSource configSource, Action<EndpointConfiguration> configurationBuilderCustomization)
        {
            var settings = runDescriptor.Settings;

            var types = endpointConfiguration.GetTypesScopedByTestClass();

            typesToInclude.AddRange(types);

            var builder = new EndpointConfiguration(endpointConfiguration.EndpointName);
            builder.TypesToIncludeInScan(typesToInclude);
            builder.CustomConfigurationSource(configSource);
            builder.EnableInstallers();

            builder.DisableFeature<TimeoutManager>();
            builder.Recoverability()
                .Delayed(delayed => delayed.NumberOfRetries(0))
                .Immediate(immediate => immediate.NumberOfRetries(0));

            await builder.DefineTransport(settings, endpointConfiguration.EndpointName).ConfigureAwait(false);

            builder.RegisterComponentsAndInheritanceHierarchy(runDescriptor);

            configurationBuilderCustomization(builder);

            return builder;
        }
        public Configure GetConfiguration(RunDescriptor runDescriptor, EndpointConfiguration endpointConfiguration,
            IConfigurationSource configSource)
        {
            Configure.ScaleOut(_ => _.UseSingleBrokerQueue());

            new Bootstrapper();

            //We need this hack here because by default we include all assemblies minus Plugins but for these tests we need to exclude other tests!
            for (var index = 0; index < Configure.TypesToScan.Count;)
            {
                var type = Configure.TypesToScan[index];

                if (type.Assembly != Assembly.GetExecutingAssembly())
                {
                    index++;
                    continue;
                }

                if (!(type.DeclaringType == endpointConfiguration.BuilderType.DeclaringType ||
                      type.DeclaringType == endpointConfiguration.BuilderType))
                {
                    Configure.TypesToScan.RemoveAt(index);
                }
                else
                {
                    index++;
                }
            }

            LogManager.Configuration = SetupLogging(endpointConfiguration);

            return Configure.Instance;
        }
Exemplo n.º 18
0
 private static ExceptionManager CreateExceptionManager(IConfigurationSource config)
 {
     var factory = new ExceptionPolicyFactory(config);
     var manger = factory.CreateManager();
     ExceptionPolicy.SetExceptionManager(manger);
     return manger;
 }
Exemplo n.º 19
0
		/// <summary>
		/// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
		/// Returns the default database name from the configuration in the <paramref name="configSource"/>, if the
		/// value for <paramref name="name"/> is <see langword="null"/> (<b>Nothing</b> in Visual Basic).
		/// </summary>
		/// <param name="name">The current name.</param>
		/// <param name="configSource">The source for configuration information.</param>
		/// <returns>The default database name if <paramref name="name"/> is <see langword="null"/> (<b>Nothing</b> in Visual Basic),
		/// otherwise the original value for <b>name</b>.</returns>
		public string MapName(string name, IConfigurationSource configSource)
		{
			if (name != null)
				return name;

			return new DatabaseConfigurationView(configSource).DefaultName;
		}
        public void SetUp()
        {
            hashProviders = new Dictionary<string, IHashProvider>();
            symmetricCrytoProviders = new Dictionary<string, ISymmetricCryptoProvider>();

            CreateKeyFile(symmetricKeyFile);
            CreateKeyFile(keyedHashKeyFile);

            configSource = ConfigurationSourceFactory.Create();

            HashProviderFactory factory = new HashProviderFactory(configSource);
            defaultHashProvider = factory.Create(hashInstance);
            hashProviders.Add(hashInstance, defaultHashProvider);

            SymmetricCryptoProviderFactory symmfactory = new SymmetricCryptoProviderFactory(configSource);
            defaultSymmetricCryptoProvider = symmfactory.Create(symmInstance);
            algorithSymmetricCryptoProvider = symmfactory.Create(symmetricAlgorithm1);

            symmetricCrytoProviders.Add(symmInstance, defaultSymmetricCryptoProvider);
            symmetricCrytoProviders.Add(symmetricAlgorithm1, algorithSymmetricCryptoProvider);

            var container = EnterpriseLibraryContainer.CreateDefaultContainer(configSource);

            cryptographyManager = container.GetInstance<CryptographyManager>();
        }
Exemplo n.º 21
0
 private static LogWriter CreateLogWriter(IConfigurationSource config)
 {
     var factory = new LogWriterFactory(config);
     var writer = factory.Create();
     Logger.SetLogWriter(writer);
     return writer;
 }
Exemplo n.º 22
0
 /// <summary>
 /// Creates the bootstrap.
 /// </summary>
 /// <param name="config">The config.</param>
 /// <returns></returns>
 public static IBootstrap CreateBootstrap(IConfigurationSource config)
 {
     if (config.Isolation == IsolationMode.AppDomain)
         return new AppDomainBootstrap(config);
     else
         return new DefaultBootstrap(config);
 }
Exemplo n.º 23
0
        public Configure GetConfiguration(RunDescriptor runDescriptor, EndpointConfiguration endpointConfiguration,
            IConfigurationSource configSource)
        {
            var settings = runDescriptor.Settings;

            var types = GetTypesScopedByTestClass(endpointConfiguration);

            var transportToUse = AcceptanceTest.GetTransportIntegrationFromEnvironmentVar();
            SetupLogging(endpointConfiguration);

            Configure.Features.Enable<Sagas>();
            Configure.ScaleOut(_ => _.UseSingleBrokerQueue());

            AddMoreConfig();

            var config = Configure.With(types)
                .DefiningEventsAs(t => typeof(IEvent).IsAssignableFrom(t) || IsExternalContract(t))
                .DefineEndpointName(endpointConfiguration.EndpointName)
                .CustomConfigurationSource(configSource)
                .DefineBuilder(settings.GetOrNull("Builder"));

            SetSerializer(config);

            config
                .DefineTransport(transportToUse)
                .InMemorySagaPersister()
                .UseInMemoryTimeoutPersister();

            if (transportToUse == null || transportToUse is MsmqTransportIntegration || transportToUse is SqlServerTransportIntegration || transportToUse is AzureStorageQueuesTransportIntegration)
            {
                config.InMemorySubscriptionStorage();
            }

            return config.UnicastBus();
        }
        public void Initialize()
        {
            ConfigurationSource = new FileConfigurationSource("typeRegistrationProviderSettings.config", false);

            TypeRegistrationProvidersSection = Given(ConfigurationSource);

        }
        public override TraceListener Assemble(IBuilderContext context, TraceListenerData objectConfiguration,
            IConfigurationSource configurationSource,
            ConfigurationReflectionCache reflectionCache)
        {
            MonitoringDatabaseTraceListenerData castedObjectConfiguration
                = (MonitoringDatabaseTraceListenerData)objectConfiguration;

            Database database =
                (Database)
                context.HeadOfChain.BuildUp(context, typeof(Database), null,
                                            castedObjectConfiguration.ConnectionStringName);
            ILogFormatter formatter
                =
                LogFormatterCustomFactory.Instance.Create(context, castedObjectConfiguration.Formatter,
                                                          configurationSource, reflectionCache);

            TraceListener createdObject
                = new MonitoringDatabaseTraceListener(
                    database,
                    formatter,
                    castedObjectConfiguration.ApplicationName,
                    castedObjectConfiguration.ConnectionStringName);

            return createdObject;
        }
Exemplo n.º 26
0
 public static void InitializeActiveRecord(IConfigurationSource source, params Type[] types)
 {
     ActiveRecordStarter.ResetInitializationFlag();
     ActiveRecordStarter.Initialize(source);
     ActiveRecordStarter.RegisterTypes(types);
     ActiveRecordStarter.CreateSchema();
 }
 public void FromConfiguration(IConfigurationSource config)
 {
     using (var host = new NullHost(config))
     {
         _metaModelRepository = host.Resolver.Resolve(typeof(IMetaModelRepository)) as IMetaModelRepository;
     }
 }
 /// <summary>
 /// Consume the set of <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.TypeRegistration"/> objects and
 /// configure the associated container.
 /// </summary>
 /// <param name="configurationSource">Configuration source to read registrations from.</param>
 /// <param name="rootProvider"><see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ITypeRegistrationsProvider"/> that knows how to
 /// read the <paramref name="configurationSource"/> and return all relevant type registrations.</param>
 public void RegisterAll(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider)
 {
     foreach (TypeRegistration registrationEntry in rootProvider.GetRegistrations(configurationSource))
     {
         Register(registrationEntry);
     }
 }
        /// <summary>
        /// Creates the <see cref="TypeRegistration"/> entries to use when configuring a container for Exception Handling
        /// </summary>
        /// <returns></returns>
        public IEnumerable<TypeRegistration> GetRegistrations(IConfigurationSource configurationSource)
        {
            var registrations = new List<TypeRegistration>();

            registrations.AddRange(GetDefaultInstrumentationRegistrations(configurationSource));

            foreach (ExceptionPolicyData policyData in ExceptionPolicies)
            {
                registrations.AddRange(policyData.GetRegistration(configurationSource));

                foreach (var policyTypeData in policyData.ExceptionTypes)
                {
                    TypeRegistration policyTypeRegistration =
                        policyTypeData.GetRegistration(policyData.Name);
                    registrations.Add(policyTypeRegistration);

                    registrations.AddRange(
                        policyTypeData.ExceptionHandlers.SelectMany(ehd => ehd.GetRegistrations(policyTypeRegistration.Name)));
                }
            }

            TypeRegistration managerRegistration =
                GetManagerRegistration(ExceptionPolicies.Select(p => p.Name).ToArray());
            managerRegistration.IsPublicName = true;

            registrations.Add(managerRegistration);

            return registrations;
        }
Exemplo n.º 30
0
 public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     DatabaseConfigurationView view = new DatabaseConfigurationView(configurationSource);
     ConnectionStringSettings connectionStringSettings = view.GetConnectionStringSettings(name);
     DbProviderMapping providerMapping = view.GetProviderMapping(name, connectionStringSettings.ProviderName);
     return this.GetAssembler(providerMapping.DatabaseType, name, reflectionCache).Assemble(name, connectionStringSettings, configurationSource);
 }
Exemplo n.º 31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationSourceChangedEventArgs"/> class.
 /// </summary>
 /// <param name="configurationSource">Configuration source that changed.</param>
 /// <param name="changedSectionNames">Sequence of the section names in <paramref name="configurationSource"/>
 /// that have changed.</param>
 public ConfigurationSourceChangedEventArgs(IConfigurationSource configurationSource,
                                            IEnumerable <string> changedSectionNames)
 {
     this.configurationSource = configurationSource;
     this.changedSectionNames = new ReadOnlyCollection <string>(changedSectionNames.ToArray());
 }
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds an <see cref="LoggingExceptionHandler"/> based on an instance of <see cref="LoggingExceptionHandlerData"/>.
        /// </summary>
        /// <seealso cref="ExceptionHandlerCustomFactory"/>
        /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
        /// <param name="objectConfiguration">The configuration object that describes the object to build. Must be an instance of <see cref="LoggingExceptionHandlerData"/>.</param>
        /// <param name="configurationSource">The source for configuration objects.</param>
        /// <param name="reflectionCache">The cache to use retrieving reflection information.</param>
        /// <returns>A fully initialized instance of <see cref="LoggingExceptionHandler"/>.</returns>
        public IExceptionHandler Assemble(IBuilderContext context, ExceptionHandlerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            LoggingExceptionHandlerData castedObjectConfiguration
                = (LoggingExceptionHandlerData)objectConfiguration;

            LogWriter writer
                = (LogWriter)context.HeadOfChain.BuildUp(context, typeof(LogWriter), null, null);

            LoggingExceptionHandler createdObject
                = new LoggingExceptionHandler(
                      castedObjectConfiguration.LogCategory,
                      castedObjectConfiguration.EventId,
                      castedObjectConfiguration.Severity,
                      castedObjectConfiguration.Title,
                      castedObjectConfiguration.Priority,
                      castedObjectConfiguration.FormatterType,
                      writer);

            return(createdObject);
        }
 public void SetUp()
 {
     EnvironmentHelper.AssertOracleClientIsInstalled();
     configurationSource = OracleTestConfigurationSource.CreateConfigurationSource();
 }
Exemplo n.º 34
0
 /// <summary>
 /// Adds the ADM instructions that describe the policies that can be used to override the properties of
 /// a specific instance of the configuration element type managed by the receiver.
 /// </summary>
 /// <param name="contentBuilder">The <see cref="AdmContentBuilder"/> to which the Adm instructions are to be appended.</param>
 /// <param name="configurationObject">The configuration object instance.</param>
 /// <param name="configurationSource">The configuration source from where to get additional configuration
 /// information, if necessary.</param>
 /// <param name="parentKey">The key path for which the generated instructions' keys must be subKeys of.</param>
 /// <remarks>
 /// ADM instructions are generated on a per-instance basis.
 /// </remarks>
 protected internal abstract void AddAdministrativeTemplateDirectives(AdmContentBuilder contentBuilder,
                                                                      ConfigurationElement configurationObject,
                                                                      IConfigurationSource configurationSource,
                                                                      String parentKey);
Exemplo n.º 35
0
 public IFunctionProvider Assemble(IBuilderContext context, FunctionProviderData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     return(new StandardFunctionProvider(objectConfiguration.Name));
 }
Exemplo n.º 36
0
 /// <summary>
 /// Adds a new configuration source.
 /// </summary>
 /// <param name="source">The configuration source to add.</param>
 /// <returns>The same <see cref="IConfigurationBuilder"/>.</returns>
 public IConfigurationBuilder Add(IConfigurationSource source !!)
 {
Exemplo n.º 37
0
#pragma warning disable CS0618
        public Task <EndpointConfiguration> GetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointConfiguration, IConfigurationSource configSource, Action <EndpointConfiguration> configurationBuilderCustomization)
#pragma warning restore CS0618
        {
            var types = endpointConfiguration.GetTypesScopedByTestClass().ToList();

            types.AddRange(ExtraTypesToInclude());

            var configuration = new EndpointConfiguration(endpointConfiguration.EndpointName);

            configuration.TypesToIncludeInScan(types);
            configuration.CustomConfigurationSource(configSource);
            configuration.EnableInstallers();


            var transportConfig = configuration.UseTransport <MsmqTransport>();
            var routingConfig   = transportConfig.Routing();

            foreach (var publisher in endpointConfiguration.PublisherMetadata.Publishers)
            {
                foreach (var eventType in publisher.Events)
                {
                    routingConfig.RegisterPublisher(eventType, publisher.PublisherName);
                }
            }

            ApplyConfig(configuration);

            var queueBindings = configuration.GetSettings().Get <QueueBindings>();

            runDescriptor.OnTestCompleted(_ => DeleteQueues(queueBindings));

            configuration.RegisterComponentsAndInheritanceHierarchy(runDescriptor);

            configuration.UsePersistence <InMemoryPersistence>();

            configuration.GetSettings().SetDefault("ScaleOut.UseSingleBrokerQueue", true);
            configurationBuilderCustomization(configuration);

            return(Task.FromResult(configuration));
        }
Exemplo n.º 38
0
 public SectionInSubordinateSource(ConfigurationSourceHandler configurationSourceHandler, string sectionName, string subordinateSourceName, IConfigurationSource subordinateSource)
 {
     this.sectionName                = sectionName;
     this.subordinateSourceName      = subordinateSourceName;
     this.configurationSourceHandler = configurationSourceHandler;
     Refresh(subordinateSource);
 }
Exemplo n.º 39
0
 public SubordinateSource(ConfigurationSourceHandler compositeConfigurationSource, string subordinateSourceName, IConfigurationSource subordinateSource)
     : this(compositeConfigurationSource, subordinateSourceName, subordinateSource, false)
 {
 }
Exemplo n.º 40
0
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="WrapHandler"/> based on an instance of <see cref="WrapHandlerData"/>.
        /// </summary>
        /// <seealso cref="ExceptionHandlerCustomFactory"/>
        /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
        /// <param name="objectConfiguration">The configuration object that describes the object to build. Must be an instance of <see cref="WrapHandlerData"/>.</param>
        /// <param name="configurationSource">The source for configuration objects.</param>
        /// <param name="reflectionCache">The cache to use retrieving reflection information.</param>
        /// <returns>A fully initialized instance of <see cref="WrapHandler"/>.</returns>
        public IExceptionHandler Assemble(IBuilderContext context, ExceptionHandlerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            WrapHandlerData castedObjectConfiguration
                = (WrapHandlerData)objectConfiguration;

            string exceptionMessage = castedObjectConfiguration.ExceptionMessage;

            if (!string.IsNullOrEmpty(castedObjectConfiguration.ExceptionMessageResourceName))
            {
                Type exceptionMessageResourceType = Type.GetType(castedObjectConfiguration.ExceptionMessageResourceType, false);

                if (null != exceptionMessageResourceType)
                {
                    exceptionMessage = ResourceStringLoader.LoadString(exceptionMessageResourceType.FullName,
                                                                       castedObjectConfiguration.ExceptionMessageResourceName,
                                                                       exceptionMessageResourceType.Assembly);
                }
            }

            WrapHandler createdObject
                = new WrapHandler(exceptionMessage, castedObjectConfiguration.WrapExceptionType);

            return(createdObject);
        }
Exemplo n.º 41
0
        /// <summary>
        /// Adds a subordinate <see cref="IConfigurationSource"/> to the <see cref="ConfigurationSourceHandler"/>.
        /// This <see cref="IConfigurationSource"/> will not be refreshed or disposed.
        /// </summary>
        /// <param name="sourceName">The name under which the <see cref="IConfigurationSource"/> will be added.</param>
        /// <param name="configurationSource">The <see cref="IConfigurationSource"/> that will be added.</param>
        protected void AddCustomSubordinateSource(string sourceName, IConfigurationSource configurationSource)
        {
            SubordinateSource sourceHolder = new SubordinateSource(this, sourceName, configurationSource, true);

            subordinateSourcesByName.Add(sourceName, sourceHolder);
        }
Exemplo n.º 42
0
            public SubordinateSource(ConfigurationSourceHandler compositeConfigurationSource, string subordinateSourceName, IConfigurationSource subordinateSource, bool customSource)
            {
                this.subordinateSourceName          = subordinateSourceName;
                this.subordinateConfigurationSource = subordinateSource;
                this.compositeConfigurationSource   = compositeConfigurationSource;
                this.customSource = customSource;

                this.subordinateConfigurationSource.SourceChanged += new EventHandler <ConfigurationSourceChangedEventArgs>(compositeConfigurationSource_ConfigurationSourceChanged);
            }
 protected override void Arrange()
 {
     MergedSource = new FileConfigurationSource(@"MergedConfigurationFile.config");
 }
Exemplo n.º 44
0
 /// <summary>
 /// Creates a new instance of <see cref="ConfigurationSourceHandler"/> passing the <see cref="IConfigurationSource"/> implementation
 /// That contains the <see cref="ConfigurationSourceSection"/> configuration.
 /// </summary>
 /// <param name="configurationSource">The <see cref="IConfigurationSource"/> implementation that should be extended.</param>
 protected ConfigurationSourceHandler(IConfigurationSource configurationSource)
 {
     this.configurationSource = configurationSource;
 }
Exemplo n.º 45
0
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Returns a new instance of a concrete subtype of <typeparamref name="TObject"/>, described by the matching configuration object
        /// of a concrete subtype of <typeparamref name="TConfiguration"/> in <paramref name="objectConfiguration"/>.
        /// </summary>
        /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
        /// <param name="objectConfiguration">The configuration object that describes the object to build.</param>
        /// <param name="configurationSource">The source for configuration objects.</param>
        /// <param name="reflectionCache">The cache to use retrieving reflection information.</param>
        /// <returns>A new instance of the appropriate subtype of <typeparamref name="Tobject"/>.</returns>
        public virtual TObject Create(IBuilderContext context, TConfiguration objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            IAssembler <TObject, TConfiguration> assembler = GetAssembler(objectConfiguration);
            TObject createdObject = assembler.Assemble(context, objectConfiguration, configurationSource, reflectionCache);

            return(createdObject);
        }
        private static TraceListener GetListener(string name, IConfigurationSource configurationSource)
        {
            var container = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource);

            return(container.GetInstance <TraceListener>(name));
        }
Exemplo n.º 47
0
 public IndividualQueueConfigurationSource(IConfigurationSource innerSource)
 {
     this.innerSource = innerSource;
 }
Exemplo n.º 48
0
        /// <summary>
        /// IQ# Magic that enables executing the Katas on Jupyter.
        /// </summary>
        public KataMagic(IOperationResolver resolver, ISnippets snippets, ILogger <KataMagic> logger, IConfigurationSource configurationSource)
        {
            this.Name          = $"%kata";
            this.Documentation = new Documentation
            {
                Summary     = "Executes a single test.",
                Description = "Executes a single test, and reports whether the test passed successfully.",
                Examples    = new []
                {
                    "To run a test called `Test`:\n" +
                    "```\n" +
                    "In []: %kata T101_StateFlip_Test \n",
                    "  ...: operation StateFlip (q : Qubit) : Unit is Adj + Ctl {\n",
                    "           // The Pauli X gate will change the |0⟩ state to the |1⟩ state and vice versa.\n",
                    "           // Type X(q);\n",
                    "           // Then run the cell using Ctrl/⌘+Enter.\n",
                    "\n",
                    "           // ...\n",
                    "       }\n" +
                    "Out[]: Qubit in invalid state. Expecting: Zero\n" +
                    "       \tExpected:\t0\n" +
                    "       \tActual:\t0.5000000000000002\n" +
                    "       Try again!" +
                    "```\n"
                }
            };
            this.Kind                = SymbolKind.Magic;
            this.Execute             = this.Run;
            this.ConfigurationSource = configurationSource;

            this.Resolver   = resolver;
            this.Snippets   = snippets;
            this.Logger     = logger;
            this.AllAnswers = new Dictionary <OperationInfo, OperationInfo>();
        }
Exemplo n.º 49
0
 protected override void AddElementAdministrativeTemplateParts(AdmContentBuilder contentBuilder, TestConfigurationElement configurationObject, IConfigurationSource configurationSource, string elementPolicyKeyName)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Exemplo n.º 50
0
        public Configure GetConfiguration(RunDescriptor runDescriptor, EndpointConfiguration endpointConfiguration, IConfigurationSource configSource)
        {
            var settings = runDescriptor.Settings;

            SetupLogging(endpointConfiguration);

            var types = GetTypesToUse(endpointConfiguration);

            var transportToUse = settings.GetOrNull("Transport");

            Configure.Features.Enable <Features.Sagas>();

            SettingsHolder.SetDefault("ScaleOut.UseSingleBrokerQueue", true);

            var config = Configure.With(types)
                         .DefineEndpointName(endpointConfiguration.EndpointName)
                         .CustomConfigurationSource(configSource)
                         .DefineBuilder(settings.GetOrNull("Builder"))
                         .DefineSerializer(settings.GetOrNull("Serializer"))
                         .DefineTransport(settings)
                         .DefineSagaPersister(settings.GetOrNull("SagaPersister"));

            if (transportToUse == null ||
                transportToUse.Contains("Msmq") ||
                transportToUse.Contains("SqlServer") ||
                transportToUse.Contains("RabbitMq"))
            {
                config.UseInMemoryTimeoutPersister();
            }

            if (transportToUse == null || transportToUse.Contains("Msmq") || transportToUse.Contains("SqlServer"))
            {
                config.DefineSubscriptionStorage(settings.GetOrNull("SubscriptionStorage"));
            }

            return(config.UnicastBus());
        }
 public IElementActionProvider Assemble(IBuilderContext context, ElementActionProviderData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     return (IElementActionProvider)Activator.CreateInstance(objectConfiguration.Type);
 }
Exemplo n.º 52
0
 protected override void AddAdministrativeTemplateDirectives(AdmContentBuilder contentBuilder, TestConfigurationElement configurationObject, IConfigurationSource configurationSource, string elementPolicyKeyName)
 {
 }
Exemplo n.º 53
0
        private static ILogFilter GetFilter(string name, IConfigurationSource configurationSource)
        {
            var settings = LoggingSettings.GetLoggingSettings(configurationSource);

            return(settings.LogFilters.Get(name).BuildFilter());
        }
 /// <summary>
 /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
 /// Builds a <see cref="BinaryLogFormatter"/> based on an instance of <see cref="BinaryLogFormatterData"/>.
 /// </summary>
 /// <seealso cref="LogFormatterCustomFactory"/>
 /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
 /// <param name="objectConfiguration">The configuration object that describes the object to build. Must be an instance of <see cref="BinaryLogFormatterData"/>.</param>
 /// <param name="configurationSource">The source for configuration objects.</param>
 /// <param name="reflectionCache">The cache to use retrieving reflection information.</param>
 /// <returns>A fully initialized instance of <see cref="BinaryLogFormatter"/>.</returns>
 public ILogFormatter Assemble(IBuilderContext context, FormatterData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     return(new BinaryLogFormatter());
 }
Exemplo n.º 55
0
        public static LogWriter CreateLogWriterFromConfigFile(
            string configFileName)
        {
            if (!string.IsNullOrWhiteSpace(configFileName))
            {
                if (Path.IsPathRooted(configFileName))
                {
                    _logConfigurationFileName = configFileName;
                }
                else
                {
                    var data = AppDomain
                               .CurrentDomain
                               .GetData("APP_CONFIG_FILE");

                    Debug.Assert(data != null);

                    var path = Path.GetDirectoryName(data.ToString());

                    configFileName            = Path.Combine(path, configFileName);
                    _logConfigurationFileName = !string.IsNullOrWhiteSpace(configFileName) && File.Exists(configFileName)
                                                            ? configFileName
                                                            : null;
                }
            }

            try
            {
                // if the file name is null or empty or does not exists - go for the app.config
                var logConfigSource = _logConfigurationFileName == null
                                                    ? (IConfigurationSource) new SystemConfigurationSource()
                                                    : (IConfigurationSource) new FileConfigurationSource(_logConfigurationFileName);
                var logger = new LogWriterFactory(logConfigSource).Create();

                if (_logConfiguration != null)
                {
                    _logConfiguration.SourceChanged -= (o, e) => Facility.FacilitiesRegistrar.RefreshLogger(
                        CreateLogWriterFromConfigFile(_logConfigurationFileName));
                    _logConfiguration.Dispose();
                }

                _logConfiguration = logConfigSource;
                _logConfiguration.SourceChanged += (o, e) => Facility.FacilitiesRegistrar.RefreshLogger(
                    CreateLogWriterFromConfigFile(_logConfigurationFileName));
                return(logger);
            }
            catch (Exception x)
            {
                if (_logConfiguration != null)
                {
                    _logConfiguration.Dispose();
                }

                // wrap and throw
                throw new ConfigurationErrorsException(
                          string.Format(
                              "There was an error loading the configuration from {0}.",
                              string.IsNullOrWhiteSpace(configFileName) ? "the system configuration file" : configFileName),
                          x);
            }
        }
Exemplo n.º 56
0
 /// <inheritdoc />
 public IConfigurationBuilder Add(IConfigurationSource source)
 {
     return(_builder.Add(source));
 }
        private static TraceListener GetListener(string name, IConfigurationSource configurationSource)
        {
            var settings = LoggingSettings.GetLoggingSettings(configurationSource);

            return(settings.TraceListeners.Get(name).BuildTraceListener(settings));
        }
Exemplo n.º 58
0
 public IConfigurationBuilder Add(IConfigurationSource source)
 {
     Sources.Add(source);
     return(this);
 }
Exemplo n.º 59
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationObjectPolicy"/> class with a configuration source.
 /// </summary>
 /// <param name="configurationSource">The configuration source.</param>
 public ConfigurationObjectPolicy(IConfigurationSource configurationSource)
 {
     this.configurationSource = configurationSource;
 }
Exemplo n.º 60
0
 public Startup(IConfigurationSource configurationSource)
 {
     this.configurationSource = configurationSource;
 }