当前位置: 首页>>代码示例>>C#>>正文


C# TraceListener.SetAttributes方法代码示例

本文整理汇总了C#中System.Diagnostics.TraceListener.SetAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# TraceListener.SetAttributes方法的具体用法?C# TraceListener.SetAttributes怎么用?C# TraceListener.SetAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Diagnostics.TraceListener的用法示例。


在下文中一共展示了TraceListener.SetAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RefreshRuntimeObject

        internal TraceListener RefreshRuntimeObject(TraceListener listener) {
            _runtimeObject = null;
            try {
                string className = TypeName;
                if (String.IsNullOrEmpty(className)) {
                    // Look it up in SharedListeners and ask the sharedListener to refresh.
                    Debug.Assert(_allowReferences, "_allowReferences must be true if type name is null");

                    if (_attributes != null || ElementInformation.Properties[_propFilter.Name].ValueOrigin == PropertyValueOrigin.SetHere || TraceOutputOptions != TraceOptions.None || !String.IsNullOrEmpty(InitData))
                        throw new ConfigurationErrorsException(SR.GetString(SR.Reference_listener_cant_have_properties, Name));

                    if (DiagnosticsConfiguration.SharedListeners == null)
                        throw new ConfigurationErrorsException(SR.GetString(SR.Reference_to_nonexistent_listener, Name));
                    
                    ListenerElement sharedListener = DiagnosticsConfiguration.SharedListeners[Name];
                    if (sharedListener == null)
                        throw new ConfigurationErrorsException(SR.GetString(SR.Reference_to_nonexistent_listener, Name));
                    else {
                        _runtimeObject = sharedListener.RefreshRuntimeObject(listener);
                        return (TraceListener) _runtimeObject;
                    }
                }
                else {
                    // We're the element with the type and initializeData info.  First see if those two are the same as they were.
                    // If not, create a whole new object, otherwise, just update the other properties.
                    if (Type.GetType(className) != listener.GetType() || InitData != listener.initializeData) {
                        // type or initdata changed
                        return GetRuntimeObject();
                    }
                    else {
                        listener.SetAttributes(Attributes);
                        listener.TraceOutputOptions = TraceOutputOptions;
                   
                        if (listener.Filter != null ) {
                            if (ElementInformation.Properties[_propFilter.Name].ValueOrigin == PropertyValueOrigin.SetHere ||
                                ElementInformation.Properties[_propFilter.Name].ValueOrigin == PropertyValueOrigin.Inherited)
                                    listener.Filter = Filter.RefreshRuntimeObject(listener.Filter);
                            else
                                listener.Filter = null;
                        }

                        _runtimeObject = listener;
                        return listener;
                    }
                }
            }
            catch (ArgumentException e) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Could_not_create_listener, Name), e);
            }
            
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:51,代码来源:ListenerElementsCollection.cs

示例2: RefreshRuntimeObject

 internal TraceListener RefreshRuntimeObject(TraceListener listener)
 {
     TraceListener listener2;
     base._runtimeObject = null;
     try
     {
         string typeName = this.TypeName;
         if (string.IsNullOrEmpty(typeName))
         {
             if (((this._attributes != null) || (base.ElementInformation.Properties[_propFilter.Name].ValueOrigin == PropertyValueOrigin.SetHere)) || ((this.TraceOutputOptions != TraceOptions.None) || !string.IsNullOrEmpty(base.InitData)))
             {
                 throw new ConfigurationErrorsException(System.SR.GetString("Reference_listener_cant_have_properties", new object[] { this.Name }));
             }
             if (DiagnosticsConfiguration.SharedListeners == null)
             {
                 throw new ConfigurationErrorsException(System.SR.GetString("Reference_to_nonexistent_listener", new object[] { this.Name }));
             }
             ListenerElement element = DiagnosticsConfiguration.SharedListeners[this.Name];
             if (element == null)
             {
                 throw new ConfigurationErrorsException(System.SR.GetString("Reference_to_nonexistent_listener", new object[] { this.Name }));
             }
             base._runtimeObject = element.RefreshRuntimeObject(listener);
             return (TraceListener) base._runtimeObject;
         }
         if ((Type.GetType(typeName) != listener.GetType()) || (base.InitData != listener.initializeData))
         {
             return this.GetRuntimeObject();
         }
         listener.SetAttributes(this.Attributes);
         listener.TraceOutputOptions = this.TraceOutputOptions;
         if ((base.ElementInformation.Properties[_propFilter.Name].ValueOrigin == PropertyValueOrigin.SetHere) || (base.ElementInformation.Properties[_propFilter.Name].ValueOrigin == PropertyValueOrigin.Inherited))
         {
             listener.Filter = this.Filter.RefreshRuntimeObject(listener.Filter);
         }
         else
         {
             listener.Filter = null;
         }
         base._runtimeObject = listener;
         listener2 = listener;
     }
     catch (ArgumentException exception)
     {
         throw new ConfigurationErrorsException(System.SR.GetString("Could_not_create_listener", new object[] { this.Name }), exception);
     }
     return listener2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:48,代码来源:ListenerElement.cs


注:本文中的System.Diagnostics.TraceListener.SetAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。