Sdílet prostřednictvím


SoapServices.GetInteropFieldTypeAndNameFromXmlElement Metoda

Definice

Načte Type a název pole ze zadaného názvu elementu XML, oboru názvů a obsahujícího typu.

public:
 static void GetInteropFieldTypeAndNameFromXmlElement(Type ^ containingType, System::String ^ xmlElement, System::String ^ xmlNamespace, [Runtime::InteropServices::Out] Type ^ % type, [Runtime::InteropServices::Out] System::String ^ % name);
public static void GetInteropFieldTypeAndNameFromXmlElement (Type containingType, string xmlElement, string xmlNamespace, out Type type, out string name);
static member GetInteropFieldTypeAndNameFromXmlElement : Type * string * string * Type * string -> unit
Public Shared Sub GetInteropFieldTypeAndNameFromXmlElement (containingType As Type, xmlElement As String, xmlNamespace As String, ByRef type As Type, ByRef name As String)

Parametry

containingType
Type

objektu Type , který obsahuje pole.

xmlElement
String

Název elementu XML pole.

xmlNamespace
String

Obor názvů XML typu pole.

type
Type

Když tato metoda vrátí hodnotu , obsahuje pole Type . Tento parametr se předává neinicializovaný.

name
String

Když tato metoda vrátí hodnotu , obsahuje parametr , String který obsahuje název pole. Tento parametr se předává neinicializovaný.

Výjimky

Bezprostřední volající nemá oprávnění k infrastruktuře.

Příklady

Následující příklad kódu ukazuje, jak tuto metodu použít. Tento příklad kódu je součástí většího příkladu SoapServices pro třídu .

// Get the name and the type of the field using its XML
// element name and its XML namespace. For this query to work,
// the containing type must be preloaded, and the XML element
// name and the XML namespace must be explicitly declared on
// the field using a SoapFieldAttribute.
// Preload the containing type.
SoapServices::PreLoad( ExampleNamespace::ExampleClass::typeid );

// Get the name and the type of a field that will be
// serialized as an XML element.
Type^ containingType = ExampleNamespace::ExampleClass::typeid;
String^ xmlElementNamespace = L"http://example.org/ExampleFieldNamespace";
String^ xmlElementName = L"ExampleFieldElementName";
Type^ fieldType;
String^ fieldName;
SoapServices::GetInteropFieldTypeAndNameFromXmlElement(
   containingType,xmlElementName,xmlElementNamespace,fieldType,fieldName );
Console::WriteLine( L"The type of the field is {0}.", fieldType );
Console::WriteLine( L"The name of the field is {0}.", fieldName );

// Get the name and the type of a field that will be
// serialized as an XML attribute.
String^ xmlAttributeNamespace =
   L"http://example.org/ExampleAttributeNamespace";
String^ xmlAttributeName = L"ExampleFieldAttributeName";
SoapServices::GetInteropFieldTypeAndNameFromXmlAttribute(
   containingType,xmlAttributeName,xmlAttributeNamespace,fieldType,fieldName );
Console::WriteLine( L"The type of the field is {0}.", fieldType );
Console::WriteLine( L"The name of the field is {0}.", fieldName );
// Get the name and the type of the field using its XML 
// element name and its XML namespace. For this query to work,
// the containing type must be preloaded, and the XML element 
// name and the XML namespace must be explicitly declared on 
// the field using a SoapFieldAttribute.

// Preload the containing type.
SoapServices.PreLoad(typeof(ExampleNamespace.ExampleClass));

// Get the name and the type of a field that will be 
// serialized as an XML element.
Type containingType = typeof(ExampleNamespace.ExampleClass);
string xmlElementNamespace = 
    "http://example.org/ExampleFieldNamespace";
string xmlElementName = "ExampleFieldElementName";
Type fieldType;
string fieldName;
SoapServices.GetInteropFieldTypeAndNameFromXmlElement(
    containingType, xmlElementName, xmlElementNamespace, 
    out fieldType, out fieldName);
Console.WriteLine(
    "The type of the field is {0}.",
    fieldType);
Console.WriteLine(
    "The name of the field is {0}.",
    fieldName);

// Get the name and the type of a field that will be 
// serialized as an XML attribute.
string xmlAttributeNamespace = 
    "http://example.org/ExampleAttributeNamespace";
string xmlAttributeName = "ExampleFieldAttributeName";
SoapServices.GetInteropFieldTypeAndNameFromXmlAttribute(
    containingType, xmlAttributeName, xmlAttributeNamespace, 
    out fieldType, out fieldName);
Console.WriteLine(
    "The type of the field is {0}.",
    fieldType);
Console.WriteLine(
    "The name of the field is {0}.",
    fieldName);

Poznámky

Vzhledem k typu obsahujícího objektu, elementu XML a oboru názvů XML, který je čten v rozhraní .NET Framework, vrátí tato metoda skutečný název pole modulu CLR (Common Language Runtime) a typ pole. Rozhraní .NET Framework pak použije tyto informace k naplnění tohoto pole daty načtenými z datového proudu XML.

Platí pro