EventSourceAttribute 类

定义

允许事件跟踪独立于事件源类的名称定义的 Windows (ETW) 名称。Allows the event tracing for Windows (ETW) name to be defined independently of the name of the event source class.

public ref class EventSourceAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class EventSourceAttribute : Attribute
public sealed class EventSourceAttribute : Attribute
type EventSourceAttribute = class
    inherit Attribute
Public NotInheritable Class EventSourceAttribute
Inherits Attribute
继承
EventSourceAttribute
属性

注解

默认情况下,在 Windows 事件跟踪(ETW)中,事件源的名称与事件源类的名称匹配,但不包含命名空间名称。By default, in event tracing for Windows (ETW), the name of an event source matches the name of the event source class, but without the namespace name. 这对于专用事件源来说已经足够,但对于更直观的事件源,最好具有分层命名空间,例如:公司名称ProviderNameThis is sufficient for private event sources, but for more visible event sources it is better to have a hierarchical namespace such as: CompanyName.ProviderName. EventSourceAttribute 特性使你可以独立于类的名称定义 ETW 名称。The EventSourceAttribute attribute lets you define the ETW name independently of the name of the class.

利用 EventSourceAttribute 属性,还可以为事件源显式定义 GUID。The EventSourceAttribute attribute also lets you define a GUID explicitly for the event source. 在标准用法中,定义事件源或引用 GUID 时,无需指定 GUID,因为 GUID 隐式派生自事件源类的名称。In standard usage, you don't need to specify a GUID when defining an event source or referring to it, because a GUID is implicitly derived from the name of the event source class. 不建议显式定义 GUID,除非使用事件源将现有 ETW 提供程序升级到。Explicitly defining a GUID is discouraged, except when upgrading existing ETW providers to using event sources.

构造函数

EventSourceAttribute()

初始化 EventSourceAttribute 类的新实例。Initializes a new instance of the EventSourceAttribute class.

属性

Guid

获取或设置事件源标识符。Gets or sets the event source identifier.

LocalizationResources

获取或设置本地化资源文件的名称。Gets or sets the name of the localization resource file.

Name

获取或设置事件源的名称。Gets or sets the name of the event source.

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute.

(继承自 Attribute)

方法

Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

(继承自 Attribute)
GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

(继承自 Attribute)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(继承自 Attribute)
Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(继承自 Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

显式接口实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

(继承自 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can be used to get the type information for an interface.

(继承自 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(继承自 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(继承自 Attribute)

适用于