Share via


SoapServices.GetInteropFieldTypeAndNameFromXmlAttribute Méthode

Définition

Récupère le type de champ à partir du nom d'attribut et de l'espace de noms XML ainsi que du Type de l'objet contenant.

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

Paramètres

containingType
Type

Type de l'objet contenant le champ.

xmlAttribute
String

Nom d'attribut XML du type de champ.

xmlNamespace
String

Espace de noms XML du type de champ.

type
Type

Lorsque cette méthode est retournée, contient un Type du champ. Ce paramètre est passé sans être initialisé.

name
String

Lorsque cette méthode est retournée, contient un String comportant le nom du champ. Ce paramètre est passé sans être initialisé.

Exceptions

L'appelant immédiat n'a pas d'autorisation d'accès à l'infrastructure.

Exemples

L'exemple de code suivant montre comment utiliser cette méthode. Cet exemple de code fait partie d’un exemple plus grand fourni pour la SoapServices classe .

// 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);

Remarques

Compte tenu du type de l’objet conteneur, de l’attribut XML et de l’espace de noms XML lus par le .NET Framework, la méthode actuelle retourne le nom et le type de champ du Common Language Runtime réels. Le .NET Framework utilise ensuite ces informations pour remplir ce champ avec les données lues à partir du flux XML.

S’applique à