Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataContractResolver::ResolveName Method (String^, String^, Type^, DataContractResolver^)

.NET Framework (current version)
 

Override this method to map the specified xsi:type name and namespace to a data contract type during deserialization.

Namespace:   System.Runtime.Serialization
Assembly:  System.Runtime.Serialization (in System.Runtime.Serialization.dll)

public:
virtual Type^ ResolveName(
	String^ typeName,
	String^ typeNamespace,
	Type^ declaredType,
	DataContractResolver^ knownTypeResolver
) abstract

Parameters

typeName
Type: System::String^

The xsi:type name to map.

typeNamespace
Type: System::String^

The xsi:type namespace to map.

declaredType
Type: System::Type^

The type declared in the data contract.

knownTypeResolver
Type: System.Runtime.Serialization::DataContractResolver^

The known type resolver.

Return Value

Type: System::Type^

The type the xsi:type name and namespace is mapped to.

If you want to use the known type resolution logic inside your implementation, a reference to it is passed in as the knownTypeResolver parameter.

The following example shows an implementation of the ResolveName method.

// Used at deserialization
// Allows users to map xsi:type name to any Type 
public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
{
    XmlDictionaryString tName;
    XmlDictionaryString tNamespace;
    if (dictionary.TryGetValue(typeName, out tName) && dictionary.TryGetValue(typeNamespace, out tNamespace))
    {
        return this.assembly.GetType(tNamespace.Value + "." + tName.Value);
    }
    else
    {
        return null;
    }
}

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2017 Microsoft