XamlTypeMapper Class

Definition

将 XAML 元素名称映射到程序集中适当的 CLR TypeMaps a XAML element name to the appropriate CLR Type in assemblies.

public ref class XamlTypeMapper
public class XamlTypeMapper
type XamlTypeMapper = class
Public Class XamlTypeMapper
Inheritance
XamlTypeMapper

Remarks

XamlTypeMapper 是为 XamlReaderXamlWriter提供备用上下文的高级 WPF 方案的一部分。XamlTypeMapper is part of an advanced WPF scenario that supplies alternate context for XamlReader and XamlWriter. 对于 .NET Framework 4.NET Framework 4 的 WPF 应用程序,应考虑覆盖此方案的 XamlSchemaContext,而不是尝试使用 XamlTypeMapperFor .NET Framework 4.NET Framework 4 WPF applications, you should consider overriding XamlSchemaContext for this scenario, rather than attempting to use XamlTypeMapper.

XamlTypeMapper 可用于向 XAML 分析器提供自定义映射信息,而不是应用程序集代码中 XmlnsDefinitionAttribute 值的应用程序。XamlTypeMapper can be used to provide the XAML parser with custom mapping information through a more direct technique than the application of XmlnsDefinitionAttribute values on the assembly code. 这对于合并程序集中的所有 CLR 命名空间或引用现有程序集中已准备好 XAML 的类型很有用,无需对其进行重新编译即可只添加 XmlnsDefinitionAttribute 特性化。This might be useful for consolidation of all CLR namespaces in an assembly, or for referencing types that are XAML-ready in an existing assembly without having to recompile it just to add XmlnsDefinitionAttribute attributing.

通常会创建 XamlTypeMapper 实例,以指定 ParserContextXamlTypeMapper 属性值。You typically create a XamlTypeMapper instance in order to specify the XamlTypeMapper property value for a ParserContext. ParserContext 反过来可用作 XamlReader.Load(Stream, ParserContext) 调用的上下文。The ParserContext in turn can be used as the context for a XamlReader.Load(Stream, ParserContext) call.

默认映射器Default Mapper

可以使用 DefaultMapper 静态属性获取默认映射器。You can obtain a default mapper using the DefaultMapper static property. 默认映射器仅适用于默认程序集列表。The default mapper only works on a default assembly list. 使用的不是有关程序集的特定信息(如 XamlTypeMapper 构造函数中指定的那样)。No specific information about assemblies (as is specified in XamlTypeMapper constructors) is used.

Constructors

XamlTypeMapper(String[])

通过指定 XamlTypeMapper 应该使用的程序集名称的数组,初始化 XamlTypeMapper 类的新实例。Initializes a new instance of the XamlTypeMapper class by specifying an array of assembly names that the XamlTypeMapper should use.

XamlTypeMapper(String[], NamespaceMapEntry[])

使用指定的程序集名称数组和指定的命名空间映射,初始化 XamlTypeMapper 类的新实例。Initializes a new instance of the XamlTypeMapper class, using the specified array of assembly names and the specified namespace maps.

Properties

DefaultMapper

获取要使用的 XamlTypeMapper 的实例(如果尚未指定)。Gets an instance of the XamlTypeMapper to use if one has not been specified.

Methods

AddMappingProcessingInstruction(String, String, String)

定义 XML 命名空间与程序集中 CLR 命名空间之间的映射,并将这些映射添加到 XamlTypeMapper 信息中。Defines a mapping between an XML namespace and CLR namespaces in assemblies, and adds these to the XamlTypeMapper information.

AllowInternalType(Type)

请求允许在完全信任的情况下调用的 XamlTypeMapper 派生类型访问特定的内部类型。Requests permission for a XamlTypeMapper derived type that is called under full trust to access a specific internal type.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType()

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

(Inherited from Object)
GetType(String, String)

使用指定的 XML 命名空间前缀和元素名称,获取给定 XAML 元素所映射到的 CLR TypeGets the CLR Type that a given XAML element is mapped to, using the specified XML namespace prefix and element name.

MemberwiseClone()

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

(Inherited from Object)
SetAssemblyPath(String, String)

指定要在加载程序集时使用的路径。Specifies the path to use when loading an assembly.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also