Example #1
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);
        }
Example #2
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);
        }
Example #3
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);
        }