SoapServices.RegisterInteropXmlElement(String, String, Type) 方法

定义

将给定 XML 元素名和命名空间与应该用于反序列化的运行时类型相关联。

public:
 static void RegisterInteropXmlElement(System::String ^ xmlElement, System::String ^ xmlNamespace, Type ^ type);
public static void RegisterInteropXmlElement (string xmlElement, string xmlNamespace, Type type);
[System.Security.SecurityCritical]
public static void RegisterInteropXmlElement (string xmlElement, string xmlNamespace, Type type);
static member RegisterInteropXmlElement : string * string * Type -> unit
[<System.Security.SecurityCritical>]
static member RegisterInteropXmlElement : string * string * Type -> unit
Public Shared Sub RegisterInteropXmlElement (xmlElement As String, xmlNamespace As String, type As Type)

参数

xmlElement
String

在反序列化中使用的 XML 元素名。

xmlNamespace
String

在反序列化中使用的 XML 命名空间。

type
Type

在反序列化中使用的运行时 Type

属性

例外

直接调用方没有基础结构权限。

示例

下面的代码示例演示如何使用此方法。 此代码示例是为 SoapServices 类提供的一个更大示例的一部分。

// Get the currently registered type for the given XML element
// and namespace.
String^ registeredXmlElementName = L"ExampleClassElementName";
String^ registeredXmlNamespace =
   L"http://example.org/ExampleXmlNamespace";
Type^ registeredType =
   SoapServices::GetInteropTypeFromXmlElement(
      registeredXmlElementName, registeredXmlNamespace );
Console::WriteLine( L"The registered interop type is {0}.",
   registeredType );

// Register a new type for the XML element and namespace.
SoapServices::RegisterInteropXmlElement(
   registeredXmlElementName,registeredXmlNamespace,String::typeid );

// Get the currently registered type for the given XML element
// and namespace.
registeredType = SoapServices::GetInteropTypeFromXmlElement(
   registeredXmlElementName,registeredXmlNamespace );
Console::WriteLine( L"The registered interop type is {0}.",
   registeredType );
// Get the currently registered type for the given XML element 
// and namespace.
string registeredXmlElementName = 
    "ExampleClassElementName";
string registeredXmlNamespace = 
    "http://example.org/ExampleXmlNamespace";
Type registeredType = 
    SoapServices.GetInteropTypeFromXmlElement(
    registeredXmlElementName, 
    registeredXmlNamespace);
Console.WriteLine(
    "The registered interop type is {0}.",
    registeredType);

// Register a new type for the XML element and namespace.
SoapServices.RegisterInteropXmlElement(
    registeredXmlElementName,
    registeredXmlNamespace, 
    typeof(String));

// Get the currently registered type for the given XML element 
// and namespace.
registeredType = 
    SoapServices.GetInteropTypeFromXmlElement(
    registeredXmlElementName, 
    registeredXmlNamespace);
Console.WriteLine(
    "The registered interop type is {0}.",
    registeredType);

适用于

另请参阅