XamlMember 类

定义

为 XAML 类型的成员提供 XAML 类型系统标识符。Provides the XAML type system identifier for members of XAML types. 该标识符由 XAML 读取器和 XAML 编写器在处理成员节点的过程中使用(如果 XAML 读取器位于 StartMember 上),另外还用于常规 XAML 类型系统逻辑。The identifier is used by XAML readers and XAML writers during processing of member nodes (when the XAML reader is positioned on a StartMember) and also for general XAML type system logic.

public ref class XamlMember : IEquatable<System::Xaml::XamlMember ^>
public class XamlMember : IEquatable<System.Xaml.XamlMember>
type XamlMember = class
    interface IEquatable<XamlMember>
Public Class XamlMember
Implements IEquatable(Of XamlMember)
继承
XamlMember
派生
实现

注解

XamlMember 可以使用三种方法来返回有关 XAML 成员的信息:标准公共语言运行时(CLR)反射;调用使用经过优化的位标志的内部 Api 的仅引用反射技术;或调入 XamlMember 子类提供的 Lookup* API 的虚拟覆盖。XamlMember can use three methodologies for returning information about a XAML member: standard common language runtime (CLR) reflection; a reference-only reflection technique calling internal APIs that use optimized bit flags; or calling into virtual overrides of the Lookup* API that is provided by possible XamlMember subclasses. 若要在大多数情况下使用 .NET Framework XAML 服务 Api 和 XamlMember API,请使用默认的 XAML 架构上下文。For most uses of .NET Framework XAML Services APIs and the XamlMember API, you use the default XAML schema context. .NET Framework XAML 服务的默认 XAML 架构上下文将 CLR 支持用于类型系统。The default XAML schema context for .NET Framework XAML Services uses CLR backing for the type system. 这使得 XAML 读取器和 XAML 编写器可以使用在中定义的任何类型或成员,也可用于 CLR 及其反射技术。This enables the XAML readers and XAML writers to work with any type or member that is defined in, or otherwise available to, the CLR and its reflection techniques.

Lookup * Api 和 XamlMember 派生类Lookup* APIs and XamlMember Derived Classes

XamlMember 定义派生类可能重写的若干虚拟成员。XamlMember defines several virtual members that derived classes might override. 这些成员的名称始终以字符串 Lookup开头。These members have names that always start with the string Lookup. 然后,API 名称的其余部分引用该虚拟方法所影响的属性。The remainder of the API name then references the property that the virtual method influences. 例如,XamlMember 派生类可能重写 LookupTargetType,以影响在派生类中 TargetType 返回的 base 定义属性。For example, a XamlMember derived class might override LookupTargetType to influence what the base-defined property TargetType returns in a derived class. 通过阅读相关 Lookup* 方法的文档,可以预测 XamlMember 或现有派生类中的此类属性的返回值。You can predict return values for such properties in XamlMember or existing derived classes by reading the documentation for the relevant Lookup* methods.

Lookup* 方法的目的是提供一个包含 XamlMember 基类的 XAML 类型系统扩展技术。The purpose of the Lookup* methods is to provide a XAML type system extension technique that incorporates the XamlMember base class. 通过从 XamlMember 和重写 Lookup 虚拟成员,您可以为 XAML 类型系统中的 XAML 架构定义 XAML 成员的概念,而不会绑定到后备类型系统或技术的具体内容。By deriving from XamlMember and overriding the Lookup virtual members, you can define the concept of a XAML member for a XAML schema in a XAML type system without being tied to the specifics of a backing type system or technology. 您还可以在此方案下使用提供的 XAML 架构上下文,并且仍返回所需的结果。You can also use a provided XAML schema context under this scheme and still return the results you want.

作为示例,请考虑 IsWritePublicXamlMember 属性。As an example, consider the XamlMember property IsWritePublic. 此属性通知调用方,如使用 XamlWriter 进行序列化等操作可以在目标对象上写入此成员的值。This property informs callers that operations such as using a XamlWriter for serialization can write a value for this member on a target object. 在默认实现中,确定成员是否可写是通过对后备 CLR Type 及其成员(MemberInfo)使用反射技术来进行的。In the default implementation, the determination of whether the member is writable is made by using reflection techniques against the backing CLR Type and its members (the MemberInfo). 因此,默认情况下,XAML 类型系统依赖于 CLR 类型系统。Therefore, by default, the XAML type system depends on the CLR type system. 但是,您可以通过重写 API LookupIsWritePublic来删除 XAML 类型系统报告 IsWritePublic 的依赖项。However, you can remove this dependency for your XAML type system reporting of IsWritePublic by overriding the API LookupIsWritePublic. 在重写中,可以使用其他确定,例如特定于技术的元数据、针对固定 XAML 词汇进行了优化的主查找表或用于确定 xaml 成员在 XAML 词汇中是否可写的各种其他策略。Within your override, you can use other determinations, such as metadata that is specific to your technology, a master lookup table that is optimized for a fixed XAML vocabulary, or a variety of other strategies for determining whether a XAML member is writable in your XAML vocabulary.

构造没有 XAML 架构上下文的 XamlMemberConstructing XamlMember Without XAML Schema Context

XamlMember 的大多数构造函数要求在初始化过程中使用 XamlSchemaContextMost constructors of XamlMember require a XamlSchemaContext as part of their initialization. 许多内部 XamlSchemaContext 操作都需要 XamlSchemaContext,例如获取从后备类型转发的信息。The XamlSchemaContext is also necessary for many internal XamlSchemaContext operations, such as obtaining information that is being forwarded from the backing type. 使用 XamlMember API 时,通常会有一个 XamlSchemaContext 可从周围的构造(如 XamlWriter)获得。When you are working with the XamlMember API, you typically have a XamlSchemaContext that is available from a surrounding construct such as a XamlWriter. 在这种情况下,可以将 XamlSchemaContext 引用传递到需要 XAML 架构上下文的所有 XAML 类型系统调用。In this case, you can pass the XamlSchemaContext reference through to all XAML type system calls that require a XAML schema context.

XamlMember(String, XamlType, Boolean)中的一个特定构造函数不需要 XamlSchemaContextOne specific constructor, XamlMember(String, XamlType, Boolean), does not require a XamlSchemaContext. 但是,使用 XamlMember(String, XamlType, Boolean) 签名构造的 XamlMember 将为 IsUnknown返回 trueHowever, a XamlMember that is constructed with the XamlMember(String, XamlType, Boolean) signature returns true for IsUnknown.

对于涉及 XamlObjectWriter的加载路径,此类成员不能写入对象关系图。For a load path that involves XamlObjectWriter, such a member cannot be written into an object graph. 使用 .NET Framework XAML 服务实现,当相关 XamlMember 报表 true IsUnknown时,XamlObjectWriter.WriteStartMember 调用将引发 XamlObjectWriterExceptionUsing the .NET Framework XAML services implementation, the XamlObjectWriter.WriteStartMember call throws a XamlObjectWriterException when the relevant XamlMember reports true for IsUnknown.

您不应构造 true 的值为 IsUnknownXamlMember,除非您的实现可以处理 XamlObjectWriter中的异常,或者您可以使用其他方法来调整 XamlObjectWriter 行为。You should not construct a XamlMember that has a value of true for IsUnknown unless your implementation can handle the exceptions from XamlObjectWriter, or you have other ways to adjust the XamlObjectWriter behavior. 例如,以下一项或多项操作可能适用于你的实现:For example, one or more of the following might be true of your implementation:

构造函数

XamlMember(EventInfo, XamlSchemaContext)

使用 CLR 类型系统 XamlMemberEventInfo 初始化 XamlSchemaContext 类的新实例。Initializes a new instance of the XamlMember class using CLR type system EventInfo and a XamlSchemaContext.

XamlMember(EventInfo, XamlSchemaContext, XamlMemberInvoker)

使用 CLR 类型系统 XamlMemberEventInfo(包括 XamlSchemaContext 信息)初始化 XamlMemberInvoker 类的新实例。Initializes a new instance of the XamlMember class using CLR type system EventInfo and a XamlSchemaContext, including XamlMemberInvoker information.

XamlMember(PropertyInfo, XamlSchemaContext)

使用 CLR 类型系统 XamlMemberPropertyInfo 初始化 XamlSchemaContext 类的新实例。Initializes a new instance of the XamlMember class using CLR type system PropertyInfo and a XamlSchemaContext.

XamlMember(PropertyInfo, XamlSchemaContext, XamlMemberInvoker)

使用反射 XamlMemberPropertyInfo(包括 XamlSchemaContext 信息)初始化 XamlMemberInvoker 类的新实例。Initializes a new instance of the XamlMember class using reflection PropertyInfo and a XamlSchemaContext, including XamlMemberInvoker information.

XamlMember(String, MethodInfo, MethodInfo, XamlSchemaContext)

针对表示可附加属性的 XamlMember 初始化 XamlMember 类的新实例。Initializes a new instance of the XamlMember class for a XamlMember that represents an attachable property.

XamlMember(String, MethodInfo, MethodInfo, XamlSchemaContext, XamlMemberInvoker)

针对表示可附加属性的 XamlMember(包括 XamlMember 信息)初始化 XamlMemberInvoker 类的新实例。Initializes a new instance of the XamlMember class for a XamlMember that represents an attachable property, including XamlMemberInvoker information.

XamlMember(String, MethodInfo, XamlSchemaContext)

针对表示可附加事件的 XamlMember 初始化 XamlMember 类的新实例。Initializes a new instance of the XamlMember class for a XamlMember that represents an attachable event.

XamlMember(String, MethodInfo, XamlSchemaContext, XamlMemberInvoker)

针对表示可附加事件的 XamlMember(包括 XamlMember 信息)初始化 XamlMemberInvoker 类的新实例。Initializes a new instance of the XamlMember class for a XamlMember that represents an attachable event, including XamlMemberInvoker information.

XamlMember(String, XamlType, Boolean)

使用字符串名称和声明 XamlMember 信息初始化 XamlType 类的新实例。Initializes a new instance of the XamlMember class using a string name and declaring XamlType information. 使用此签名构造的 XamlMember 具有很大的限制。A XamlMember that is constructed with this signature has significant limitations.

属性

DeclaringType

获取类型的 XamlType,该类型声明与此 XamlMember 关联的成员。Gets the XamlType for the type that declares the member that is associated with this XamlMember.

DeferringLoader

获取一个 XamlValueConverter<TConverterBase> 对象,该对象用于 XAML 声明的对象的延迟加载。Gets a XamlValueConverter<TConverterBase> object, which is used for deferred loading of XAML declared objects.

DependsOn

获取 XamlMember 对象的列表。Gets a list of XamlMember objects. 这些对象报告一些成员,其中的初始化顺序依赖关系相对于此 XamlMember 存在。These report the members where dependency relationships for initialization order exist relative to this XamlMember.

Invoker

获取与此 XamlMemberInvoker 关联的 XamlMember 实现。Gets the XamlMemberInvoker implementation that is associated with this XamlMember.

IsAmbient

获取一个值,该值指示是否将此 XamlMember 报告为一个环境属性。Gets a value that indicates whether this XamlMember is reported as an ambient property.

IsAttachable

获取一个值,该值指示此 XamlMember 是否为可附加成员。Gets a value that indicates whether this XamlMember is an attachable member.

IsDirective

获取一个值,该值指示此 XamlMember 是否为 XAML 指令。Gets a value that indicates whether this XamlMember is a XAML directive.

IsEvent

获取一个值,该值指示此 XamlMember 是否表示事件成员。Gets a value that indicates whether this XamlMember represents an event member.

IsNameValid

获取一个值,该值指示是否使用有效的 xamlName 字符串作为其 XamlMember 来初始化此 NameGets a value that indicates whether this XamlMember is initialized with a valid xamlName string as its Name.

IsReadOnly

获取一个值,该值指示此 XamlMember 是否表示只读成员。Gets a value that indicates whether this XamlMember represents a read-only member.

IsReadPublic

获取一个值,该值指示此 XamlMember 是否表示一个具有可调用公共 get 访问器的成员。Gets a value that indicates whether this XamlMember represents a member with a callable public get accessor.

IsUnknown

获取一个值,该值指示用于类型和成员解析的支持系统是否无法解析成员。Gets a value that indicates whether the member is not resolvable by the backing system that is used for type and member resolution.

IsWriteOnly

获取一个值,该值指示此 XamlMember 是否表示只写成员。Gets a value that indicates whether this XamlMember represents a write-only member.

IsWritePublic

获取一个值,该值指示此 XamlMember 是否表示一个具有可调用公共 set 访问器的成员。Gets a value that indicates whether this XamlMember represents a member that has a callable public set accessor.

MarkupExtensionBracketCharacters

定义标记扩展的开始和结束括号字符。Defines the opening and closing bracket characters for a markup extension.

Name

获取 xamlName 名称字符串,该字符串声明此 XamlMemberGets the xamlName name string that declares this XamlMember.

PreferredXamlNamespace

获取单个 XAML 命名空间 URI,该 URI 标识此 XamlMember 的主 XAML 命名空间。Gets the single XAML namespace URI that identifies the primary XAML namespace for this XamlMember.

SerializationVisibility

获取一个 DesignerSerializationVisibility 值,该值指示可视化设计器应如何处理成员。Gets a DesignerSerializationVisibility value, which indicates how a visual designer should process the member.

TargetType

获取其中可能存在 XamlType 的类型的 XamlMemberGets the XamlType of the type where the XamlMember can exist.

Type

获取成员所使用的类型的 XamlTypeGets the XamlType of the type that is used by the member.

TypeConverter

获取一个 XamlValueConverter<TConverterBase> 对象,该对象可用于 XAML 声明的对象的类型转换构造。Gets a XamlValueConverter<TConverterBase> object, which can be used for type conversion construction of XAML declared objects.

UnderlyingMember

获取 CLR 类型系统 MemberInfo,它可用于由 PropertyInfoMethodInfoEventInfo 构造的成员。Gets the CLR type system MemberInfo that is available for a member that is constructed by PropertyInfo, MethodInfo, or EventInfo.

ValueSerializer

获取一个 XamlValueConverter<TConverterBase> 对象,该对象用于 XAML 声明的对象的值序列化。Gets a XamlValueConverter<TConverterBase> object, which is used for value serialization of XAML declared objects.

方法

Equals(Object)

指示当前对象是否等于另一个对象。Indicates whether the current object is equal to another object.

Equals(XamlMember)

指示当前对象是否等于同一类型的另一个对象。Indicates whether the current object is equal to another object of the same type.

GetHashCode()

返回该对象的哈希代码。Returns the hash code for this object.

GetType()

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

(继承自 Object)
GetXamlNamespaces()

返回 XAML 命名空间的列表,此 XAML 成员可能存在于这些命名空间中。Returns a list of XAML namespaces where this XAML member can exist.

LookupCustomAttributeProvider()

在派生类中实现时,返回 ICustomAttributeProvider 实现。When implemented in a derived class, returns an ICustomAttributeProvider implementation.

LookupDeferringLoader()

返回一个 XamlValueConverter<TConverterBase> 对象,该对象用于 XAML 声明的对象的延迟加载。Returns a XamlValueConverter<TConverterBase> object, which is used for deferred loading of XAML declared objects.

LookupDependsOn()

返回 XamlMember 对象的列表。Returns a list of XamlMember objects. 此列表中的项报告一些成员,其中的初始化顺序依赖关系相对于此 XamlMember 存在。Items in the list report the members where dependency relationships for initialization order exist relative to this XamlMember.

LookupInvoker()

返回与此 XamlMemberInvoker 关联的 XamlMemberReturns a XamlMemberInvoker that is associated with this XamlMember.

LookupIsAmbient()

返回的值指示是否将此 XamlMember 作为环境属性报告。Returns whether this XamlMember is reported as an ambient property.

LookupIsEvent()

返回的值指示此 XamlMember 是否表示一个事件。Returns whether this XamlMember represents an event.

LookupIsReadOnly()

返回的值指示此 XamlMember 是否表示预期的只读属性。Returns whether this XamlMember represents an intended read-only property.

LookupIsReadPublic()

返回的值指示此 XamlMember 是否表示一个具有公共 get 访问器的属性。Returns whether this XamlMember represents a property that has a public get accessor.

LookupIsUnknown()

返回的值指示此 XamlMember 是否表示一个用于类型和成员解析的支持系统无法解析的成员。Returns whether this XamlMember represents a member that is not resolvable by the backing system that is used for type and member resolution.

LookupIsWriteOnly()

返回的值指示此 XamlMember 是否表示一个具有公共 set 访问器但没有公共 get 访问器的成员。Returns whether this XamlMember represents a member that has a public set accessor but not a public get accessor.

LookupIsWritePublic()

返回的值指示此 XamlMember 是否表示一个具有公共 set 访问器的成员。Returns whether this XamlMember represents a member that has a public set accessor.

LookupMarkupExtensionBracketCharacters()

返回标记扩展的开始和结束括号字符。Returns the opening and closing bracket characters for a markup extension.

LookupTargetType()

返回其中可能存在 XamlType 的类型的 XamlMemberReturns the XamlType of the type where the XamlMember can exist.

LookupType()

返回成员所使用的类型的 XamlTypeReturns the XamlType of the type that is used by the member.

LookupTypeConverter()

返回与此 XamlMember 关联的类型转换器实现。Returns a type converter implementation that is associated with this XamlMember.

LookupUnderlyingGetter()

返回与此 XamlMember 关联的 get 访问器。Returns a get accessor that is associated with this XamlMember.

LookupUnderlyingMember()

返回与此 MemberInfo 关联的 CLR 类型系统 XamlMemberReturns a CLR type system MemberInfo that is associated with this XamlMember.

LookupUnderlyingSetter()

返回与此 XamlMember 关联的 set 访问器。Returns a set accessor that is associated with this XamlMember.

LookupValueSerializer()

返回与此 XamlMember 关联的值序列化程序实现。Returns a value serializer implementation that is associated with this XamlMember.

MemberwiseClone()

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

(继承自 Object)
ToString()

返回此 XamlMember 的字符串表示形式。Returns a string representation of this XamlMember.

运算符

Equality(XamlMember, XamlMember)

确定两个指定的 XamlMember 对象是否具有相同的值。Determines whether two specified XamlMember objects have the same value.

Inequality(XamlMember, XamlMember)

确定两个指定的 XamlMember 对象是否具有不同的值。Determines whether two specified XamlMember objects have different values.

适用于

另请参阅