共用方式為


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

定義

傳回 XML 項目資訊,其應該在指定型別序列化時使用。

public:
 static bool GetXmlElementForInteropType(Type ^ type, [Runtime::InteropServices::Out] System::String ^ % xmlElement, [Runtime::InteropServices::Out] System::String ^ % xmlNamespace);
public static bool GetXmlElementForInteropType (Type type, out string xmlElement, out string xmlNamespace);
[System.Security.SecurityCritical]
public static bool GetXmlElementForInteropType (Type type, out string xmlElement, out string xmlNamespace);
static member GetXmlElementForInteropType : Type * string * string -> bool
[<System.Security.SecurityCritical>]
static member GetXmlElementForInteropType : Type * string * string -> bool
Public Shared Function GetXmlElementForInteropType (type As Type, ByRef xmlElement As String, ByRef xmlNamespace As String) As Boolean

參數

type
Type

對其要求 XML 項目和命名空間名稱的物件 Type

xmlElement
String

當這個方法傳回時,含有存有所指定物件型別之 XML 項目名稱的 String。 這個參數會以未初始化的狀態傳遞。

xmlNamespace
String

當這個方法傳回時,含有存有所指定物件型別之 XML 命名空間名稱的 String。 這個參數會以未初始化的狀態傳遞。

傳回

如果要求的值以 SoapTypeAttribute 設定旗標,則為 true,否則為 false

屬性

例外狀況

立即呼叫端沒有基礎結構使用權限。

範例

下列程式碼範例會顯示如何使用這個方法。 此程式代碼範例是提供給 類別之較大範例的 SoapServices 一部分。

// Get the XML element name and the XML namespace for
// an Interop type.
String^ xmlElement;
bool isSoapTypeAttribute = SoapServices::GetXmlElementForInteropType(
   ExampleNamespace::ExampleClass::typeid,xmlElement,xmlNamespace );

// Print whether the requested value was flagged
// with a SoapTypeAttribute.
if ( isSoapTypeAttribute )
{
   Console::WriteLine( L"The requested value was flagged "
   L"with the SoapTypeAttribute." );
}
else
{
   Console::WriteLine( L"The requested value was not flagged "
   L"with the SoapTypeAttribute." );
}

// Print the XML element and the XML namespace.
Console::WriteLine( L"The XML element for the type "
L"ExampleNamespace.ExampleClass is {0}.", xmlElement );
Console::WriteLine( L"The XML namespace for the type "
L"ExampleNamespace.ExampleClass is {0}.", xmlNamespace );
// Get the XML element name and the XML namespace for 
// an Interop type.
string xmlElement;
bool isSoapTypeAttribute =
    SoapServices.GetXmlElementForInteropType(
    typeof(ExampleNamespace.ExampleClass), 
    out xmlElement, out xmlNamespace);

// Print whether the requested value was flagged 
// with a SoapTypeAttribute.
if (isSoapTypeAttribute)
{
    Console.WriteLine(
        "The requested value was flagged " +
        "with the SoapTypeAttribute.");
}
else 
{
    Console.WriteLine(
        "The requested value was not flagged " +
        "with the SoapTypeAttribute.");
}

// Print the XML element and the XML namespace.
Console.WriteLine(
    "The XML element for the type " +
    "ExampleNamespace.ExampleClass is {0}.",
    xmlElement);
Console.WriteLine(
    "The XML namespace for the type " +
    "ExampleNamespace.ExampleClass is {0}.",
    xmlNamespace);

適用於

另請參閱