XamlTypeMapper 类

定义

将 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
继承
XamlTypeMapper

注解

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此方案进行重写, 而不是XamlTypeMapper尝试使用。For .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实例, 以便为XamlTypeMapper指定属性值ParserContextYou typically create a XamlTypeMapper instance in order to specify the XamlTypeMapper property value for a ParserContext. 反过来可用作XamlReader.Load(Stream, ParserContext)调用的上下文。 ParserContextThe 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.

构造函数

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.

属性

DefaultMapper

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

方法

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.

(继承自 Object)
GetHashCode()

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

(继承自 Object)
GetType()

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

(继承自 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.

(继承自 Object)
SetAssemblyPath(String, String)

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

ToString()

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

(继承自 Object)

适用于

另请参阅