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);
 }
        private static CachingInstrumentationProvider CreateInstrumentationProvider(string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            CachingInstrumentationProvider instrumentationProvider = new CachingInstrumentationProvider();
            new InstrumentationAttachmentStrategy().AttachInstrumentation(name, instrumentationProvider, configurationSource, reflectionCache);

            return instrumentationProvider;
        }
 private InstrumentationListenerAttribute GetInstrumentationListenerAttribute(object createdObject, ConfigurationReflectionCache reflectionCache)
 {
     Type createdObjectType = createdObject.GetType();
     InstrumentationListenerAttribute listenerAttribute
         = reflectionCache.GetCustomAttribute<InstrumentationListenerAttribute>(createdObjectType, true);
     return listenerAttribute;
 }
        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;
        }
 public void SetUp()
 {
     factory = new MockAssembledObjectFactory();
     context = new MockBuilderContext();
     configurationSource = new DictionaryConfigurationSource();
     reflectionCache = new ConfigurationReflectionCache();
 }
        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;
        }
示例#7
0
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Returns an <see cref="IDatabaseAssembler"/> that represents the building process for a a concrete <see cref="Database"/>.
        /// </summary>
        /// <param name="type">The concrete <see cref="Database"/> type.</param>
        /// <param name="name">The name of the instance to build, or <see langword="null"/> (<b>Nothing</b> in Visual Basic).</param>
        /// <param name="reflectionCache">The cache to use retrieving reflection information.</param>
        /// <returns>The <see cref="IDatabaseAssembler"/> instance.</returns>
        /// <exception cref="InvalidOperationException">when concrete <see cref="Database"/> type does have the required <see cref="DatabaseAssemblerAttribute"/>.</exception>
        public IDatabaseAssembler GetAssembler(Type type, string name, ConfigurationReflectionCache reflectionCache)
        {
            bool exists = false;
            IDatabaseAssembler assembler;
            lock (assemblersMappingLock)
            {
                exists = assemblersMapping.TryGetValue(type, out assembler);
            }
            if (!exists)
            {
                DatabaseAssemblerAttribute assemblerAttribute
                    = reflectionCache.GetCustomAttribute<DatabaseAssemblerAttribute>(type);
                if (assemblerAttribute == null)
                    throw new InvalidOperationException(
                        string.Format(
                            Resources.Culture,
                            Resources.ExceptionDatabaseTypeDoesNotHaveAssemblerAttribute,
                            type.FullName,
                            name));

                assembler
                    = (IDatabaseAssembler)Activator.CreateInstance(assemblerAttribute.AssemblerType);

                lock (assemblersMappingLock)
                {
                    assemblersMapping[type] = assembler;
                }
            }

            return assembler;
        }
		public void SetUp()
		{
			configurationSource = new DictionaryConfigurationSourceWithHandlersQuery();

			InstrumentationConfigurationSection instrumentationConfig = new InstrumentationConfigurationSection(true, true, true);
			configurationSource.Add(InstrumentationConfigurationSection.SectionName, instrumentationConfig);

			settings = new LoggingSettings();
			configurationSource.Add(LoggingSettings.SectionName, settings);

			settings.SpecialTraceSources.ErrorsTraceSource
				= new TraceSourceData("error", SourceLevels.Off);

			TraceSourceData traceSourceData = new TraceSourceData("blocking", SourceLevels.All);
			traceSourceData.TraceListeners.Add(new TraceListenerReferenceData("listener1"));
			settings.TraceSources.Add(traceSourceData);
			traceSourceData = new TraceSourceData("nonblocking", SourceLevels.All);
			traceSourceData.TraceListeners.Add(new TraceListenerReferenceData("listener2"));
			settings.TraceSources.Add(traceSourceData);

			TraceListenerData traceListenerData = new CustomTraceListenerData("listener1", typeof(MockBlockingCustomTraceListener), "init 1");
			settings.TraceListeners.Add(traceListenerData);
			traceListenerData = new MockTraceListenerData("listener2");
			settings.TraceListeners.Add(traceListenerData);

			reflectionCache = new ConfigurationReflectionCache();

			MockTraceListener.Reset();
			MockBlockingCustomTraceListener.Reset();
		}
		public void SetUp()
		{
			MockBuilderContext builderContext = new MockBuilderContext();
			builderContext.InnerChain.Add(new ConfiguredObjectStrategy());
			context = builderContext;
			reflectionCache = new ConfigurationReflectionCache();
		}
        ///<summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code. 
        /// Builds a <see cref="CommonLoggingEntlibTraceListener"/> described by a 
        /// <see cref="CommonLoggingEntlibTraceListenerData"/> configuration object. 
        ///</summary>
        public override TraceListener Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            CommonLoggingEntlibTraceListenerData data = (CommonLoggingEntlibTraceListenerData)objectConfiguration;
            ILogFormatter formatter = base.GetFormatter(context, data.Formatter, configurationSource, reflectionCache);

            CommonLoggingEntlibTraceListener listener = (CommonLoggingEntlibTraceListener)System.Activator.CreateInstance(objectConfiguration.Type, new object[] { objectConfiguration, formatter });
            return listener;
        }
 public void CreateConfigurationSource()
 {
     instrumentationConfigurationSource = new DictionaryConfigurationSource();
     instrumentationConfigurationSource.Add(InstrumentationConfigurationSection.SectionName,
                                            new InstrumentationConfigurationSection(true, true, true));
     strategy = new InstrumentationAttachmentStrategy();
     reflectionCache = new ConfigurationReflectionCache();
 }
		/// <summary>
		/// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
		/// </summary>
		/// <param name="context">Represents the context in which a build-up or tear-down runs.</param>
		/// <param name="name">Unused parameter</param>
		/// <param name="configurationSource">Represents a source for getting configuration</param>
		/// <param name="reflectionCache">Unused parameter.</param>
		/// <returns>Fully initialized instance of a default event logging object</returns>
		public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
		{
			InstrumentationConfigurationSection objectConfiguration	= GetConfiguration(configurationSource);

			object createdObject = DoCreateObject((objectConfiguration));

			return createdObject;
		}
示例#13
0
        /// <summary>
        /// Returns an new instance of the type the receiver knows how to build.
        /// </summary>
        /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
        /// <param name="name">The name of the instance to build, or null.</param>
        /// <param name="configurationSource">The source for configuration objects.</param>
        /// <param name="reflectionCache">The cache to use retrieving reflection information.</param>
        /// <returns>The new instance.</returns>
        public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            DatabaseConfigurationView databaseConfigurationView = new DatabaseConfigurationView(configurationSource);            
            ConnectionStringSettings connectionStringSettings = databaseConfigurationView.GetConnectionStringSettings(name);
            DbSchemaProviderConfigurationView dbSchemaProviderConfigurationView = new DbSchemaProviderConfigurationView(configurationSource);
            DbSchemaProviderMapping mapping = dbSchemaProviderConfigurationView.GetProviderMapping(connectionStringSettings.ProviderName);

            return Activator.CreateInstance(mapping.DbSchemaProviderType);
        }
		public void ExplicitBinderInstanceReturnedIfTwoArgumentAttributeOnSourceClass()
		{
			ExplicitBindingSource source = new ExplicitBindingSource();
			InstrumentationAttacherFactory factory = new InstrumentationAttacherFactory();
			ConfigurationReflectionCache reflectionCache = new ConfigurationReflectionCache();

			IInstrumentationAttacher createdAttacher = factory.CreateBinder(source, new object[0], reflectionCache);
			
			Assert.AreSame(typeof (ExplicitInstrumentationAttacher), createdAttacher.GetType());
		}
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="DefaultLoggingEventLogger"/>.
        /// </summary>
        /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
        /// <param name="name">The name of the instance to build. It is part of the <see cref="ICustomFactory.CreateObject(IBuilderContext, string, IConfigurationSource, ConfigurationReflectionCache)"/> method, but it is not used in this implementation.</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="DefaultLoggingEventLogger"/>.</returns>
        public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            InstrumentationConfigurationSection objectConfiguration
                = GetConfiguration(configurationSource);

            DefaultLoggingEventLogger createdObject
                = new DefaultLoggingEventLogger(objectConfiguration.EventLoggingEnabled, objectConfiguration.WmiEnabled);

            return createdObject;
        }
		public void NoBinderInstanceReturnedIfNoAttributeOnSourceClass()
		{
			NoListenerSource source = new NoListenerSource();
			InstrumentationAttacherFactory factory = new InstrumentationAttacherFactory();
			ConfigurationReflectionCache reflectionCache = new ConfigurationReflectionCache();

			IInstrumentationAttacher createdAttacher = factory.CreateBinder(source, new object[0], reflectionCache);
			
			Assert.AreSame(typeof(NoBindingInstrumentationAttacher), createdAttacher.GetType());
		}
		/// <summary>
		/// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
		/// Builds a <see cref="TracerInstrumentationListener"/>.
		/// </summary>
		/// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
		/// <param name="name">The name of the instance to build. It is part of the <see cref="ICustomFactory.CreateObject(IBuilderContext, string, IConfigurationSource, ConfigurationReflectionCache)"/> method, but it is not used in this implementation.</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="TracerInstrumentationListener"/>.</returns>
		public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            InstrumentationConfigurationSection objectConfiguration
                = GetConfiguration(configurationSource);

            TracerInstrumentationListener createdObject
                = new TracerInstrumentationListener(objectConfiguration.PerformanceCountersEnabled);

            return createdObject;
        }
		/// <summary>
		/// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
		/// Builds a <see cref="XmlTraceListener"/> based on an instance of <see cref="XmlTraceListenerData"/>.
		/// </summary>
		/// <seealso cref="TraceListenerCustomFactory"/>
		/// <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="XmlTraceListenerData"/>.</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="XmlTraceListener"/>.</returns>
		public override TraceListener Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
		{
			XmlTraceListenerData castedObjectConfiguration
				= (XmlTraceListenerData)objectConfiguration;

			XmlTraceListener createdObject
				= new XmlTraceListener(castedObjectConfiguration.FileName);

			return createdObject;
		}
        public void InstrumentationIsNotAttachedIfConfigurationIsMissing()
        {
            DictionaryConfigurationSource dictionary = new DictionaryConfigurationSource();
            InstrumentationAttachmentStrategy attacher = new InstrumentationAttachmentStrategy();
            ConfigurationReflectionCache reflectionCache = new ConfigurationReflectionCache();

            SourceObject sourceObject = new SourceObject();
            attacher.AttachInstrumentation(sourceObject, dictionary, reflectionCache);

            Assert.IsFalse(ShouldNeverBeInstantiatedListener.WasInstantiated);
        }
示例#20
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 <see cref="Database"/>, described by the <see cref="ConnectionStringSettings"/> 
        /// found in the <paramref name="configurationSource"/> under the name <paramref name="name"/>, plus any additional
        /// configuration information that might describe the the concrete <b>Database</b>.
        /// </summary>
        /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
        /// <param name="name">The name of the instance to build, or <see langword="null"/> (<b>Nothing</b> in Visual Basic).</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>
        /// <exception cref="ConfigurationErrorsException">when the configuration is invalid or <paramref name="name"/> cannot be found.</exception>
        public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            DatabaseConfigurationView configurationView = new DatabaseConfigurationView(configurationSource);
            ConnectionStringSettings connectionStringSettings = configurationView.GetConnectionStringSettings(name);
            DbProviderMapping mapping = configurationView.GetProviderMapping(name, connectionStringSettings.ProviderName);

            IDatabaseAssembler assembler = GetAssembler(mapping.DatabaseType, name, reflectionCache);
            Database database = assembler.Assemble(name, connectionStringSettings, configurationSource);

            return database;
        }
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="TraceListener"/> based on an instance of <see cref="SystemDiagnosticsTraceListenerData"/>.
        /// </summary>
        /// <remarks>
        /// The building process for non Enterprise Library specific <see cref="TraceListener"/>s mimics the creation process used by System.Diagnostics' configuration.
        /// </remarks>
        /// <seealso cref="TraceListenerCustomFactory"/>
        /// <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="SystemDiagnosticsTraceListenerData"/>.</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 a <see cref="TraceListener"/> subclass.</returns>
        public override TraceListener Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            BasicCustomTraceListenerData castedObjectConfiguration
                = (BasicCustomTraceListenerData)objectConfiguration;

            Type type = castedObjectConfiguration.Type;
            string name = castedObjectConfiguration.Name;
            TraceOptions traceOutputOptions = castedObjectConfiguration.TraceOutputOptions;
            string initData = castedObjectConfiguration.InitData;
            NameValueCollection attributes = castedObjectConfiguration.Attributes;

            TraceListener traceListener = null;
            if (String.IsNullOrEmpty(initData))
            {
                ConstructorInfo defaultConstructor = type.GetConstructor(Type.EmptyTypes);
                if (defaultConstructor != null)
                {
                    traceListener = (TraceListener)defaultConstructor.Invoke(emptyParameters);
                }
                else
                {
                    throw new InvalidOperationException(
                        string.Format(Resources.Culture,
                        Resources.ExceptionCustomListenerTypeDoesNotHaveDefaultConstructor,
                        name,
                        type.FullName));
                }
            }
            else
            {
                try
                {
                    traceListener = (TraceListener)Activator.CreateInstance(type, initData);
                }
                catch (MissingMethodException exception)
                {
                    throw new InvalidOperationException(
                        string.Format(
                            Resources.Culture,
                            Resources.ExceptionCustomTraceListenerTypeDoesNotHaveRequiredConstructor,
                            name,
                            type.FullName),
                        exception);
                }
            }

            foreach (string attribute in attributes.Keys)
            {
                traceListener.Attributes.Add(attribute, attributes.Get(attribute));
            }

            return traceListener;
        }
        public IInstrumentationAttacher CreateBinder(object createdObject, object[] constructorArgs, ConfigurationReflectionCache reflectionCache)
        {
            InstrumentationListenerAttribute listenerAttribute = GetInstrumentationListenerAttribute(createdObject, reflectionCache);

            if (listenerAttribute == null) return new NoBindingInstrumentationAttacher();

            Type listenerType = listenerAttribute.ListenerType;
            Type listenerBinderType = listenerAttribute.ListenerBinderType;

            if(listenerBinderType == null) return new ReflectionInstrumentationAttacher(createdObject, listenerType, constructorArgs);
            return new ExplicitInstrumentationAttacher(createdObject, listenerType, constructorArgs, listenerBinderType);
        }
 private void AttachInstrumentation(ArgumentGenerator arguments, object createdObject, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     InstrumentationConfigurationSection configurationSection = this.GetConfigurationSection(configurationSource);
     if (!configurationSection.InstrumentationIsEntirelyDisabled)
     {
         if (createdObject is IInstrumentationEventProvider)
         {
             createdObject = ((IInstrumentationEventProvider) createdObject).GetInstrumentationEventProvider();
         }
         object[] constructorArgs = arguments.ToArguments(configurationSection);
         this.BindInstrumentationTo(createdObject, constructorArgs, reflectionCache);
     }
 }
示例#24
0
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a custom trace listener based on an instance of <see cref="CustomTraceListenerData"/>.
        /// </summary>
        /// <seealso cref="TraceListenerCustomFactory"/>
        /// <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="CustomTraceListenerData"/>.</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 custom trace listener.</returns>
        public override TraceListener Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            TraceListener createdObject = base.Assemble(context, objectConfiguration, configurationSource, reflectionCache);

            if (createdObject is CustomTraceListener)
            {
                CustomTraceListenerData castedObjectConfiguration
                    = (CustomTraceListenerData)objectConfiguration;
                ILogFormatter formatter = GetFormatter(context, castedObjectConfiguration.Formatter, configurationSource, reflectionCache);
                ((CustomTraceListener)createdObject).Formatter = formatter;
            }

            return createdObject;
        }
        public void InstrumentationIsNotAttachedIfAllConfigOptionsAreFalse()
        {
            DictionaryConfigurationSource dictionary = new DictionaryConfigurationSource();
            dictionary.Add(InstrumentationConfigurationSection.SectionName,
                new InstrumentationConfigurationSection(false, false, false));

            InstrumentationAttachmentStrategy attacher = new InstrumentationAttachmentStrategy();
            ConfigurationReflectionCache reflectionCache = new ConfigurationReflectionCache();

            SourceObject sourceObject = new SourceObject();
            attacher.AttachInstrumentation(sourceObject, dictionary, reflectionCache);

            Assert.IsFalse(ShouldNeverBeInstantiatedListener.WasInstantiated);
        }
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="FlatFileTraceListener"/> based on an instance of <see cref="FlatFileTraceListenerData"/>.
        /// </summary>
        /// <seealso cref="TraceListenerCustomFactory"/>
        /// <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="FlatFileTraceListenerData"/>.</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="FlatFileTraceListener"/>.</returns>
        public override TraceListener Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            FlatFileTraceListenerData castedObjectConfiguration
                = (FlatFileTraceListenerData)objectConfiguration;

            ILogFormatter formatter = GetFormatter(context, castedObjectConfiguration.Formatter, configurationSource, reflectionCache);

            TraceListener createdObject
                = new FlatFileTraceListener(
                    castedObjectConfiguration.FileName,
                    castedObjectConfiguration.Header,
                    castedObjectConfiguration.Footer,
                    formatter);

            return createdObject;
        }
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="ExceptionPolicyEntry"/> based on an instance of <see cref="ExceptionTypeData"/>.
        /// </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 fully initialized instance of <see cref="ExceptionPolicyEntry"/>.</returns>
		public ExceptionPolicyEntry Create(IBuilderContext context, ExceptionTypeData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
		{
			List<IExceptionHandler> handlers = new List<IExceptionHandler>();
			foreach (ExceptionHandlerData handlerData in objectConfiguration.ExceptionHandlers)
			{
				IExceptionHandler handler
					= ExceptionHandlerCustomFactory.Instance.Create(context, handlerData, configurationSource, reflectionCache);
				handlers.Add(handler);
			}

			ExceptionPolicyEntry createdObject
				= new ExceptionPolicyEntry(
					objectConfiguration.PostHandlingAction,
					handlers);

			return createdObject;
		}
示例#28
0
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds an <see cref="EmailTraceListener"/> based on an instance of <see cref="EmailTraceListenerData"/>.
        /// </summary>
        /// <seealso cref="TraceListenerCustomFactory"/>
        /// <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="EmailTraceListenerData"/>.</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="EmailTraceListener"/>.</returns>
        public override TraceListener Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            EmailTraceListenerData castedObjectConfiguration
                = (EmailTraceListenerData)objectConfiguration;

            ILogFormatter formatter = GetFormatter(context, castedObjectConfiguration.Formatter, configurationSource, reflectionCache);

            TraceListener createdObject
                = new EmailTraceListener(
                    castedObjectConfiguration.ToAddress,
                    castedObjectConfiguration.FromAddress,
                    castedObjectConfiguration.SubjectLineStarter,
                    castedObjectConfiguration.SubjectLineEnder,
                    castedObjectConfiguration.SmtpServer,
                    castedObjectConfiguration.SmtpPort,
                    formatter);

            return createdObject;
        }
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="FormattedDatabaseTraceListener"/> based on an instance of <see cref="FormattedDatabaseTraceListenerData"/>.
        /// </summary>
        /// <seealso cref="TraceListenerCustomFactory"/>
        /// <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="FormattedDatabaseTraceListenerData"/>.</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="FormattedDatabaseTraceListener"/>.</returns>
        public override TraceListener Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            FormattedDatabaseTraceListenerData castedObjectConfiguration
                = (FormattedDatabaseTraceListenerData)objectConfiguration;

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

            TraceListener createdObject
                = new FormattedDatabaseTraceListener(
                    database,
                    castedObjectConfiguration.WriteLogStoredProcName,
                    castedObjectConfiguration.AddCategoryStoredProcName,
                    formatter);

            return createdObject;
        }
        public object CreateObject(Microsoft.Practices.ObjectBuilder.IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            TerminologyServiceSettings settings =
                configurationSource.GetSection(TerminologyServiceSettings.SectionName) as TerminologyServiceSettings;

            Check.Assert(settings != null, "settings must not be null.");
            TerminologyServiceData data = settings.TerminologyServiceProviders.Get(name) as TerminologyServiceData;
            if (data == null)
                throw new ConfigurationErrorsException("Unable to find Terminology service provider. " + name);

            Dictionary<string, ICodeSetAccess> codeSetAccessDictionary = new Dictionary<string, ICodeSetAccess>();

            foreach (CodeSetAccessProviderData codeSetAccessProviderData in data.codeSetAccessProviders)
            {
                codeSetAccessDictionary.Add(codeSetAccessProviderData.Name,
                    (ICodeSetAccess)CodeSetAccessProviderCustomFactory.Instance.Create
                    (context, codeSetAccessProviderData, configurationSource, reflectionCache));
            }

            Dictionary<string, ITerminologyAccess> terminologyAccessDictionary = new Dictionary<string, ITerminologyAccess>();

            foreach (TerminologyAccessProviderData terminologyAccessProviderData in data.TerminologyAccessProviders)
            {
                terminologyAccessDictionary.Add(terminologyAccessProviderData.Name,
                    (ITerminologyAccess)TerminologyAccessProviderCustomFactory.Instance.Create
                    (context, terminologyAccessProviderData, configurationSource, reflectionCache));
            }

            ITerminologyService terminologyService = new TerminologyService(terminologyAccessDictionary, codeSetAccessDictionary);

            if (context.Locator != null)
            {
                ILifetimeContainer lifetime = context.Locator.Get<ILifetimeContainer>(typeof(ILifetimeContainer), SearchMode.Local);
                if (lifetime != null)
                {
                    context.Locator.Add(new DependencyResolutionLocatorKey(typeof(ITerminologyServiceProvider), name), terminologyService);
                    lifetime.Add(terminologyService);
                }
            }

            return terminologyService;
        }
示例#31
0
 public ITypeManagerTypeHandler Assemble(IBuilderContext context, TypeManagerTypeHandlerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     return((ITypeManagerTypeHandler)Activator.CreateInstance(objectConfiguration.Type));
 }
 public IUiControlFactory Assemble(IBuilderContext context, UiControlFactoryData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     return(new TemplatedTextInputUiControlFactory(objectConfiguration as TemplatedTextInputUiControlFactoryData));
 }
        /// <exclude />
        public ILoginProvider Assemble(Microsoft.Practices.ObjectBuilder.IBuilderContext context, LoginProviderData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            if (null == objectConfiguration)
            {
                throw new ArgumentNullException("objectConfiguration");
            }

            return((ILoginProvider)Activator.CreateInstance(objectConfiguration.Type));
        }
示例#34
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 <see cref="Database"/>, described by the <see cref="ConnectionStringSettings"/>
        /// found in the <paramref name="configurationSource"/> under the name <paramref name="name"/>, plus any additional
        /// configuration information that might describe the the concrete <b>Database</b>.
        /// </summary>
        /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
        /// <param name="name">The name of the instance to build, or <see langword="null"/> (<b>Nothing</b> in Visual Basic).</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 .</returns>
        /// <exception cref="ConfigurationErrorsException">when the configuration is invalid or <paramref name="name"/> cannot be found.</exception>
        public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            DatabaseConfigurationView configurationView        = new DatabaseConfigurationView(configurationSource);
            ConnectionStringSettings  connectionStringSettings = configurationView.GetConnectionStringSettings(name);
            DbProviderMapping         mapping = configurationView.GetProviderMapping(name, connectionStringSettings.ProviderName);

            IDatabaseAssembler assembler = GetAssembler(mapping.DatabaseType, name, reflectionCache);
            Database           database  = assembler.Assemble(name, connectionStringSettings, configurationSource);

            return(database);
        }
 public ILoginSessionStore Assemble(Microsoft.Practices.ObjectBuilder.IBuilderContext context, LoginSessionStoreData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     return((ILoginSessionStore)Activator.CreateInstance(objectConfiguration.Type));
 }
示例#36
0
        /// <summary>
        /// Builds an instance of the subtype of IMatchingRule type the receiver knows how to build, based on
        /// a configuration object.
        /// </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 fully initialized instance of the IMatchingRule subtype.</returns>
        public IMatchingRule Assemble(IBuilderContext context, MatchingRuleData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            TypeMatchingRuleData castedRuleData = (TypeMatchingRuleData)objectConfiguration;
            List <MatchingInfo>  matches        = new List <MatchingInfo>();

            foreach (MatchData match in castedRuleData.Matches)
            {
                matches.Add(new MatchingInfo(match.Match, match.IgnoreCase));
            }
            TypeMatchingRule matchingRule = new TypeMatchingRule(matches);

            return(matchingRule);
        }
 public IHookRegistrator Assemble(IBuilderContext context, HookRegistratorData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     return((IHookRegistrator)Activator.CreateInstance(objectConfiguration.Type));
 }
 public void SetUp()
 {
     context         = new MockBuilderContext();
     reflectionCache = new ConfigurationReflectionCache();
 }
示例#39
0
 public IGlobalSettingsProvider Assemble(IBuilderContext context, GlobalSettingsProviderData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     return(new ConfigBasedGlobalSettingsProvider((ConfigBasedGlobalSettingsProviderData)objectConfiguration));
 }
 public void SetUp()
 {
     context         = new BuilderContext(new StrategyChain(), null, null, new PolicyList(), null, null);
     reflectionCache = new ConfigurationReflectionCache();
 }
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="KeyedHashAlgorithmProvider"/> based on an instance of <see cref="KeyedHashAlgorithmProviderData"/>.
        /// </summary>
        /// <seealso cref="HashProviderCustomFactory"/>
        /// <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="KeyedHashAlgorithmProviderData"/>.</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="KeyedHashAlgorithmProvider"/>.</returns>
        public IHashProvider Assemble(IBuilderContext context, HashProviderData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            KeyedHashAlgorithmProviderData castedObjectConfiguration
                = (KeyedHashAlgorithmProviderData)objectConfiguration;

            IHashProvider createdObject
                = new KeyedHashAlgorithmProvider(
                      castedObjectConfiguration.AlgorithmType,
                      castedObjectConfiguration.SaltEnabled,
                      castedObjectConfiguration.ProtectedKeyFilename,
                      castedObjectConfiguration.ProtectedKeyProtectionScope);

            return(createdObject);
        }
示例#42
0
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="MsmqTraceListener"/> based on an instance of <see cref="MsmqTraceListenerData"/>.
        /// </summary>
        /// <seealso cref="TraceListenerCustomFactory"/>
        /// <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="MsmqTraceListenerData"/>.</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="MsmqTraceListener"/>.</returns>
        public override TraceListener Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            MsmqTraceListenerData castedObjectConfiguration
                = (MsmqTraceListenerData)objectConfiguration;

            ILogFormatter formatter = GetFormatter(context, castedObjectConfiguration.Formatter, configurationSource, reflectionCache);

            TraceListener createdObject
                = new MsmqTraceListener(
                      castedObjectConfiguration.Name,
                      castedObjectConfiguration.QueuePath,
                      formatter,
                      castedObjectConfiguration.MessagePriority,
                      castedObjectConfiguration.Recoverable,
                      castedObjectConfiguration.TimeToReachQueue,
                      castedObjectConfiguration.TimeToBeReceived,
                      castedObjectConfiguration.UseAuthentication,
                      castedObjectConfiguration.UseDeadLetterQueue,
                      castedObjectConfiguration.UseEncryption,
                      castedObjectConfiguration.TransactionType);

            return(createdObject);
        }
示例#43
0
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="SymmetricAlgorithmProvider"/> based on an instance of <see cref="SymmetricAlgorithmProviderData"/>.
        /// </summary>
        /// <seealso cref="SymmetricCryptoProviderCustomFactory"/>
        /// <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="SymmetricAlgorithmProviderData"/>.</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="SymmetricAlgorithmProvider"/>.</returns>
        public ISymmetricCryptoProvider Assemble(IBuilderContext context, SymmetricProviderData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            SymmetricAlgorithmProviderData castedObjectConfiguration
                = (SymmetricAlgorithmProviderData)objectConfiguration;

            ISymmetricCryptoProvider createdObject
                = new SymmetricAlgorithmProvider(
                      castedObjectConfiguration.AlgorithmType,
                      castedObjectConfiguration.ProtectedKeyFilename,
                      castedObjectConfiguration.ProtectedKeyProtectionScope);

            return(createdObject);
        }
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="TraceListener"/> based on an instance of <see cref="SystemDiagnosticsTraceListenerData"/>.
        /// </summary>
        /// <remarks>
        /// The building process for non Enterprise Library specific <see cref="TraceListener"/>s mimics the creation process used by System.Diagnostics' configuration.
        /// </remarks>
        /// <seealso cref="TraceListenerCustomFactory"/>
        /// <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="SystemDiagnosticsTraceListenerData"/>.</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 a <see cref="TraceListener"/> subclass.</returns>
        public override TraceListener Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            BasicCustomTraceListenerData castedObjectConfiguration
                = (BasicCustomTraceListenerData)objectConfiguration;

            Type                type = castedObjectConfiguration.Type;
            string              name = castedObjectConfiguration.Name;
            TraceOptions        traceOutputOptions = castedObjectConfiguration.TraceOutputOptions;
            string              initData           = castedObjectConfiguration.InitData;
            NameValueCollection attributes         = castedObjectConfiguration.Attributes;

            TraceListener traceListener = null;

            if (String.IsNullOrEmpty(initData))
            {
                ConstructorInfo defaultConstructor = type.GetConstructor(Type.EmptyTypes);
                if (defaultConstructor != null)
                {
                    traceListener = (TraceListener)defaultConstructor.Invoke(emptyParameters);
                }
                else
                {
                    throw new InvalidOperationException(
                              string.Format(Resources.Culture,
                                            Resources.ExceptionCustomListenerTypeDoesNotHaveDefaultConstructor,
                                            name,
                                            type.FullName));
                }
            }
            else
            {
                try
                {
                    traceListener = (TraceListener)Activator.CreateInstance(type, initData);
                }
                catch (MissingMethodException exception)
                {
                    throw new InvalidOperationException(
                              string.Format(
                                  Resources.Culture,
                                  Resources.ExceptionCustomTraceListenerTypeDoesNotHaveRequiredConstructor,
                                  name,
                                  type.FullName),
                              exception);
                }
            }

            foreach (string attribute in attributes.Keys)
            {
                traceListener.Attributes.Add(attribute, attributes.Get(attribute));
            }

            return(traceListener);
        }
        public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            InstrumentationConfigurationSection objectConfiguration
                = GetConfiguration(configurationSource);
            DefaultLoggingEventLogger createdObject
                = new DefaultLoggingEventLogger(objectConfiguration.EventLoggingEnabled, objectConfiguration.WmiEnabled);

            return(createdObject);
        }
 public abstract TraceListener Assemble(IBuilderContext context, TraceListenerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache);
        public IUserPermissionDefinitionProvider Assemble(IBuilderContext context, UserPermissionDefinitionProviderData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            ConfigBasedUserPermissionDefinitionProviderData data = (ConfigBasedUserPermissionDefinitionProviderData)objectConfiguration;

            return(new ConfigBasedUserPermissionDefinitionProvider(data));
        }
        protected ILogFormatter GetFormatter(IBuilderContext context, string formatterName, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            ILogFormatter formatter
                = string.IsNullOrEmpty(formatterName)
                                        ? null
                                        : LogFormatterCustomFactory.Instance.Create(context, formatterName, configurationSource, reflectionCache);

            return(formatter);
        }
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="ExceptionPolicyEntry"/> based on an instance of <see cref="ExceptionTypeData"/>.
        /// </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 fully initialized instance of <see cref="ExceptionPolicyEntry"/>.</returns>
        public ExceptionPolicyEntry Create(IBuilderContext context, ExceptionTypeData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            List <IExceptionHandler> handlers = new List <IExceptionHandler>();

            foreach (ExceptionHandlerData handlerData in objectConfiguration.ExceptionHandlers)
            {
                IExceptionHandler handler
                    = ExceptionHandlerCustomFactory.Instance.Create(context, handlerData, configurationSource, reflectionCache);
                handlers.Add(handler);
            }

            ExceptionPolicyEntry createdObject
                = new ExceptionPolicyEntry(
                      objectConfiguration.Type,
                      objectConfiguration.PostHandlingAction,
                      handlers);

            return(createdObject);
        }
        public ILogFilter Assemble(IBuilderContext context, LogFilterData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            LogEnabledFilterData castedObjectConfiguration = (LogEnabledFilterData)objectConfiguration;
            ILogFilter           createdObject
                = new LogEnabledFilter(
                      castedObjectConfiguration.Name,
                      castedObjectConfiguration.Enabled);

            return(createdObject);
        }
示例#51
0
 public void SetUp()
 {
     reflectionCache     = new ConfigurationReflectionCache();
     configurationSource = new SystemConfigurationSource();
 }
 public IUrlFormatter Assemble(IBuilderContext context, UrlFormatterData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     return((IUrlFormatter)Activator.CreateInstance(objectConfiguration.Type));
 }
 public IPageTemplateProvider Assemble(IBuilderContext context, PageTemplateProviderData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     return((IPageTemplateProvider)Activator.CreateInstance(objectConfiguration.Type));
 }
示例#54
0
        /// <summary>
        /// Builds an instance of the subtype of <typeparamref name="TObject"/> type the receiver knows how to build,  based on
        /// an a configuration object.
        /// </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 fully initialized instance of the <typeparamref name="TObject"/> subtype.</returns>
        public ICallHandler Assemble(IBuilderContext context, CallHandlerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            ValidationCallHandlerData castedHandlerData = (ValidationCallHandlerData)objectConfiguration;

            ValidationCallHandler callHandler = new ValidationCallHandler(castedHandlerData.RuleSet, castedHandlerData.SpecificationSource);

            return(callHandler);
        }
示例#55
0
        public IDataProvider Assemble(IBuilderContext context, DataProviderData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            var sqlDataProviderData = (SqlDataProviderData)objectConfiguration;

            string configFilePath = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.ConfigurationDirectory), string.Format("{0}.config", sqlDataProviderData.Name));
            var    configuration  = new C1Configuration(configFilePath);

            var section = configuration.GetSection(SqlDataProviderConfigurationSection.SectionName) as SqlDataProviderConfigurationSection;

            if (section == null)
            {
                section = new SqlDataProviderConfigurationSection();
                configuration.Sections.Add(SqlDataProviderConfigurationSection.SectionName, section);
                configuration.Save();
            }


            var interfaceConfigurationElements = new List <InterfaceConfigurationElement>();

            foreach (InterfaceConfigurationElement table in section.Interfaces)
            {
                interfaceConfigurationElements.Add(table);
            }

            var sqlLoggingContext = new SqlLoggingContext
            {
                Enabled        = sqlDataProviderData.SqlQueryLoggingEnabled,
                IncludeStack   = sqlDataProviderData.SqlQueryLoggingIncludeStack,
                TypesToIgnore  = new List <Type>(),
                TablesToIgnore = new List <string>()
            };

            if (sqlDataProviderData.SqlQueryLoggingEnabled)
            {
                foreach (LoggingIgnoreInterfacesConfigurationElement element in sqlDataProviderData.LoggingIgnoreInterfaces)
                {
                    Type interfaceType = TypeManager.TryGetType(element.InterfaceType);
                    if (interfaceType != null)
                    {
                        sqlLoggingContext.TypesToIgnore.Add(interfaceType);

                        InterfaceConfigurationElement interfaceElement = interfaceConfigurationElements.SingleOrDefault(f => f.DataTypeId == interfaceType.GetImmutableTypeId());
                        if (interfaceElement == null)
                        {
                            continue;
                        }

                        foreach (StoreConfigurationElement store in interfaceElement.ConfigurationStores)
                        {
                            sqlLoggingContext.TablesToIgnore.Add(store.TableName);
                        }
                    }
                }
            }


            string connectionString = sqlDataProviderData.ConnectionString;

            if (string.IsNullOrEmpty(connectionString))
            {
                string connectionStringName = sqlDataProviderData.ConnectionStringName;

                if (string.IsNullOrEmpty(connectionStringName))
                {
                    throw new ConfigurationErrorsException("SqlDataProvider requires one of the following properties to be specified: 'connectionString', 'connectionStringName'");
                }

                var connStringConfigNode = System.Web.Configuration.WebConfigurationManager.ConnectionStrings[connectionStringName];
                Verify.IsNotNull(connStringConfigNode, "Failed to find an SQL connection string by name '{0}'", connectionStringName);

                connectionString = connStringConfigNode.ConnectionString;
            }

            return(new SqlDataProvider(connectionString, interfaceConfigurationElements, sqlLoggingContext));
        }
 public IHooklessElementProvider Assemble(IBuilderContext context, HooklessElementProviderData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     return(new PageElementProvider());
 }
示例#57
0
        IPasswordRule IAssembler <IPasswordRule, PasswordRuleData> .Assemble(IBuilderContext context, PasswordRuleData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            var data = (MinimumLengthPasswordRuleData)objectConfiguration;

            return(new MinimumLengthPasswordRule(data.MinLength));
        }
示例#58
0
        public IPageTemplateProvider Assemble(Microsoft.Practices.ObjectBuilder.IBuilderContext context, PageTemplateProviderData objectConfiguration, Microsoft.Practices.EnterpriseLibrary.Common.Configuration.IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            var data = objectConfiguration as MasterPagePageTemplateProviderData;

            if (data == null)
            {
                throw new ArgumentException("Expected configuration to be of type " + typeof(MasterPagePageTemplateProviderAssembler).Name,
                                            "objectConfiguration");
            }

            Type addNewTemplateWorkflow = null;

            if (!string.IsNullOrEmpty(data.AddNewTemplateWorkflow))
            {
                try
                {
                    addNewTemplateWorkflow = TypeManager.GetType(data.AddNewTemplateWorkflow);
                }
                catch (Exception ex)
                {
                    Log.LogError(this.GetType().FullName, ex);
                }
            }

            string folderPath = PathUtil.Resolve(data.Directory);

            if (!C1Directory.Exists(folderPath))
            {
                throw new ConfigurationErrorsException("Folder '{0}' does not exists".FormatWith(folderPath),
                                                       objectConfiguration.ElementInformation.Source, objectConfiguration.ElementInformation.LineNumber);
            }

            return(new MasterPagePageTemplateProvider(data.Name, data.Directory, data.AddNewTemplateLabel, addNewTemplateWorkflow));
        }
示例#59
0
        /// <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);
        }
示例#60
0
 public IRenderingResponseHandler Assemble(IBuilderContext context, RenderingResponseHandlerData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
 {
     return((IRenderingResponseHandler)Activator.CreateInstance(objectConfiguration.Type));
 }