public void CreateConfigurationSource()
 {
     instrumentationConfigurationSource = new DictionaryConfigurationSource();
     instrumentationConfigurationSource.Add(InstrumentationConfigurationSection.SectionName,
                                            new InstrumentationConfigurationSection(true, true, true, "fooApplicationInstanceName"));
     strategy        = new InstrumentationAttachmentStrategy();
     reflectionCache = new ConfigurationReflectionCache();
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public LogSource Create(IBuilderContext context, TraceSourceData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache, TraceListenerCustomFactory.TraceListenerCache traceListenersCache)
        {
            List <TraceListener> traceListeners = new List <TraceListener>(objectConfiguration.TraceListeners.Count);

            foreach (TraceListenerReferenceData traceListenerReference in objectConfiguration.TraceListeners)
            {
                TraceListener traceListener
                    = TraceListenerCustomFactory.Instance.Create(context, traceListenerReference.Name, configurationSource, reflectionCache, traceListenersCache);
                traceListeners.Add(traceListener);
            }
            LogSource createdObject
                = new LogSource(objectConfiguration.Name, traceListeners, objectConfiguration.DefaultLevel, objectConfiguration.AutoFlush);
            InstrumentationAttachmentStrategy instrumentationAttacher = new InstrumentationAttachmentStrategy();

            instrumentationAttacher.AttachInstrumentation(createdObject, configurationSource, reflectionCache);
            return(createdObject);
        }