示例#1
0
        /// <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);
        }
        private InstrumentationConfigurationSection GetConfigurationSection(IConfigurationSource configurationSource)
        {
            InstrumentationConfigurationSection section =
                (InstrumentationConfigurationSection)configurationSource.GetSection(InstrumentationConfigurationSection.SectionName);

            if (section == null)
            {
                section = new InstrumentationConfigurationSection(false, false, false);
            }

            return(section);
        }
 public object[] ToArguments(InstrumentationConfigurationSection configSection)
 {
     return(instanceName == null
                                     ?
            new object[] { configSection.PerformanceCountersEnabled, configSection.EventLoggingEnabled, configSection.WmiEnabled }
                                     :
            new object[]
     {
         instanceName, configSection.PerformanceCountersEnabled, configSection.EventLoggingEnabled,
         configSection.WmiEnabled
     });
 }
        private void AttachInstrumentation(ArgumentGenerator arguments, object createdObject,
                                           IConfigurationSource configurationSource,
                                           ConfigurationReflectionCache reflectionCache)
        {
            InstrumentationConfigurationSection section = GetConfigurationSection(configurationSource);

            if (section.InstrumentationIsEntirelyDisabled)
            {
                return;
            }

            if (createdObject is IInstrumentationEventProvider)
            {
                createdObject = ((IInstrumentationEventProvider)createdObject).GetInstrumentationEventProvider();
            }

            object[] constructorArgs = arguments.ToArguments(section);

            BindInstrumentationTo(createdObject, constructorArgs, reflectionCache);
        }
示例#5
0
 /// <summary>
 /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
 /// Builds an initialized default event logging object.
 /// </summary>
 /// <param name="instrumentationConfigurationSection">The instrumentation section that is used as configuration.</param>
 /// <returns>A fully initialized instance of a default event logging object.</returns>
 protected abstract object DoCreateObject(InstrumentationConfigurationSection instrumentationConfigurationSection);