internal TracerConfig(string cfg)
        {
            if (string.IsNullOrEmpty(cfg))
            {
                return;
            }

            var source = new TraceSource(TraceEnvVarName, SourceLevels.All);
            this.myListeners = source.Listeners;

            var parser = new TraceCfgParser(cfg);
            var newListener = parser.OutDevice;
            this.myFilters = parser.Filters;
            this.myNotFilters = parser.NotFilters;

            if (newListener != null)
            {
                // when the App.config _Trace source should be used we do not replace
                // anything
                if (!parser.UseAppConfigListeners)
                {
                    this.myListeners.Clear();
                    this.myListeners.Add(newListener);
                }
            }
            else
            {
                this.myListeners = null;
            }
        }
        public TraceFilter GetRuntimeObject()
        {
            TraceFilter newFilter = (TraceFilter)BaseGetRuntimeObject();

            newFilter.initializeData = InitData;
            return(newFilter);
        }
Пример #3
0
        public TraceFilter GetRuntimeObject()
        {
            TraceFilter filter = (TraceFilter)base.BaseGetRuntimeObject();

            filter.initializeData = base.InitData;
            return(filter);
        }
Пример #4
0
        /// <param name="filter">The TraceFilter included in the MultiFilter's specified FilterGroup</param>
        /// <param name="negate">Indicates whether the result of the filter should be inversed when ShouldTrace is evaluated (i.e True -> False and False - True). 
        /// Specify true to negate the result or false to leave as is.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if the filter argument is null</exception>
        public MultiFilterMember(TraceFilter filter, bool negate)
        {
            if (null == filter)
                throw new ArgumentNullException("filter");

            Negate = negate;
            Filter = filter;
        }
 internal TraceFilter RefreshRuntimeObject(TraceFilter filter)
 {
     if (!(Type.GetType(this.TypeName) != filter.GetType()) && !(base.InitData != filter.initializeData))
     {
         return filter;
     }
     base._runtimeObject = null;
     return this.GetRuntimeObject();
 }
Пример #6
0
 internal TraceFilter RefreshRuntimeObject(TraceFilter filter)
 {
     if (!(Type.GetType(this.TypeName) != filter.GetType()) && !(base.InitData != filter.initializeData))
     {
         return(filter);
     }
     base._runtimeObject = null;
     return(this.GetRuntimeObject());
 }
Пример #7
0
 internal TraceFilter RefreshRuntimeObject(TraceFilter filter) {
     if (Type.GetType(TypeName) != filter.GetType() || InitData != filter.initializeData) {
         // type or initdata changed
         _runtimeObject = null;
         return GetRuntimeObject();
     }
     else {
         return filter;
     }
 }
 internal TraceFilter RefreshRuntimeObject(TraceFilter filter)
 {
     if (Type.GetType(TypeName) != filter.GetType() || InitData != filter.initializeData)
     {
         // type or initdata changed
         _runtimeObject = null;
         return(GetRuntimeObject());
     }
     else
     {
         return(filter);
     }
 }
        /// <summary>
        ///     Format string is of the form
        ///     outDevice; type flag1+flag2+...;type flags; ...
        ///     where flags are a combination of trace markers
        /// </summary>
        /// <param name="config"></param>
        public TraceCfgParser(string config)
        {
            if (string.IsNullOrEmpty(config))
            {
                return;
            }

            var parts = config.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(str => str.Trim()).ToArray();

            foreach (var filter in this.GetFilters(parts, 1).Reverse())
            {
                var typeName = filter.Key.TrimStart('!');
                var bIsNotFilter = filter.Key.IndexOf('!') == 0;

                var levelAndMsgFilter = this.ParseMsgTypeFilter(filter.Value);

                var curFilterInstance = new TraceFilter(typeName, levelAndMsgFilter.Value, levelAndMsgFilter.Key, bIsNotFilter ? this.NotFilters : this.Filters);

                if (bIsNotFilter)
                {
                    this.NotFilters = curFilterInstance;
                }
                else
                {
                    this.Filters = curFilterInstance;
                }
            }

            if (parts.Length > 0)
            {
                this.OpenOutputDevice(parts[0].ToLower());
            }

            // when only output device was configured or wrong mask was entere we enable full tracing
            // by default
            if (this.Filters == null)
            {
                this.Filters = new TraceFilterMatchAll();
            }

            if (this.bHasError)
            {
                InternalError.PrintHelp();
            }
        }
 public IocWrapperTraceFilter(string objectName)
 {
     traceFilter = ContextRegistry.GetContext().GetObject(objectName) as TraceFilter;
 }