Evaluar y enviar comentarios

  Encender vista de ancho de banda bajo
Esta página es específica de
Microsoft Visual Studio 2008/.NET Framework 3.5

Hay además otras versiones disponibles para:
Biblioteca de clases de .NET Framework
SoapServices..::.GetInteropFieldTypeAndNameFromXmlElement (Método)

Actualización: noviembre 2007

Recupera el tipo (Type) y el nombre de un campo a partir del nombre de elemento XML, el espacio de nombres y el tipo contenedor especificados.

Espacio de nombres:  System.Runtime.Remoting
Ensamblado:  mscorlib (en mscorlib.dll)
Visual Basic (Declaración)
Public Shared Sub GetInteropFieldTypeAndNameFromXmlElement ( _
    containingType As Type, _
    xmlElement As String, _
    xmlNamespace As String, _
    <OutAttribute> ByRef type As Type, _
    <OutAttribute> ByRef name As String _
)
Visual Basic (Uso)
Dim containingType As Type
Dim xmlElement As String
Dim xmlNamespace As String
Dim type As Type
Dim name As String

SoapServices.GetInteropFieldTypeAndNameFromXmlElement(containingType, _
    xmlElement, xmlNamespace, type, name)
C#
public static void GetInteropFieldTypeAndNameFromXmlElement(
    Type containingType,
    string xmlElement,
    string xmlNamespace,
    out Type type,
    out string name
)
Visual C++
public:
static void GetInteropFieldTypeAndNameFromXmlElement(
    Type^ containingType, 
    String^ xmlElement, 
    String^ xmlNamespace, 
    [OutAttribute] Type^% type, 
    [OutAttribute] String^% name
)
J#
public static void GetInteropFieldTypeAndNameFromXmlElement(
    Type containingType,
    String xmlElement,
    String xmlNamespace,
    /** @attribute OutAttribute */ /** @ref */Type type,
    /** @attribute OutAttribute */ /** @ref */String name
)
JScript
public static function GetInteropFieldTypeAndNameFromXmlElement(
    containingType : Type, 
    xmlElement : String, 
    xmlNamespace : String, 
    type : Type, 
    name : String
)

Parámetros

containingType
Tipo: System..::.Type
Type del objeto que contiene el campo.
xmlElement
Tipo: System..::.String
Nombre de campo del elemento XML.
xmlNamespace
Tipo: System..::.String
Espacio de nombres XML del tipo de campo.
type
Tipo: System..::.Type%
Cuando este método finaliza, contiene un objeto Type del campo. Este parámetro se pasa sin inicializar.
name
Tipo: System..::.String%
Cuando este método finaliza, contiene una cadena (String) con el nombre del campo. Este parámetro se pasa sin inicializar.
ExcepciónCondición
SecurityException

El llamador inmediato no tiene permisos de infraestructura.

Dado el tipo del objeto contenedor, el elemento XML y el espacio de nombres XML leído por .NET Framework, este método devuelve el nombre de campo y el tipo de campo reales de Common Language Runtime. .NET Framework utiliza entonces esta información para rellenar ese campo con los datos leídos de la secuencia XML.

En el ejemplo de código siguiente se muestra la forma de utilizar este método. Este ejemplo de código forma parte de un ejemplo más extenso referente a la clase SoapServices.

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

Visual C++
// 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 );

J#
// 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.class.ToType());
// Get the name and the type of a field that will be 
// serialized as an XML element.
Type containingType = ExampleNamespace.ExampleClass.class.ToType();
String xmlElementNamespace = "http://example.org/ExampleFieldNamespace";
String xmlElementName = "ExampleFieldElementName";
Type fieldType = null;
String fieldName = "";
SoapServices.GetInteropFieldTypeAndNameFromXmlElement(containingType, 
    xmlElementName, xmlElementNamespace, fieldType, 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, fieldType, fieldName);
Console.WriteLine("The type of the field is {0}.", fieldType);
Console.WriteLine("The name of the field is {0}.", fieldName);

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

.NET Framework

Compatible con: 3.5, 3.0, 2.0, 1.1, 1.0
Contenido de la comunidad   ¿Qué es Community Content?
Agregar contenido nuevo RSS  Anotaciones
Processing
© 2009 Microsoft Corporation. Reservados todos los derechos. Términos de uso  |  Marcas Registradas  |  Privacidad
Page view tracker