Export (0) Print
Expand All

SoapServices.GetInteropFieldTypeAndNameFromXmlElement Method

Retrieves the Type and name of a field from the provided XML element name, namespace, and the containing type.

Namespace:  System.Runtime.Remoting
Assembly:  mscorlib (in mscorlib.dll)

public static void GetInteropFieldTypeAndNameFromXmlElement(
	Type containingType,
	string xmlElement,
	string xmlNamespace,
	out Type type,
	out string name
)

Parameters

containingType
Type: System.Type

The Type of the object that contains the field.

xmlElement
Type: System.String

The XML element name of field.

xmlNamespace
Type: System.String

The XML namespace of the field type.

type
Type: System.Type

When this method returns, contains a Type of the field. This parameter is passed uninitialized.

name
Type: System.String

When this method returns, contains a String that holds the name of the field. This parameter is passed uninitialized.

ExceptionCondition
SecurityException

The immediate caller does not have infrastructure permission.

Given the type of the containing object and the XML element and XML namespace that is read in by the .NET Framework, this method returns the actual common language runtime field name and type of the field. The .NET Framework then uses this information to populate that field with the data read in from the XML stream.

The following code example shows how to use this method. This code example is part of a larger example provided for the SoapServices class.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Show:
© 2015 Microsoft