DataContractResolver.ResolveName(String, String, Type, DataContractResolver) メソッド

定義

このメソッドをオーバーライドして、逆シリアル化中に指定された xsi:type 名と名前空間をデータ コントラクト型にマップします。Override this method to map the specified xsi:type name and namespace to a data contract type during deserialization.

public:
 abstract Type ^ ResolveName(System::String ^ typeName, System::String ^ typeNamespace, Type ^ declaredType, System::Runtime::Serialization::DataContractResolver ^ knownTypeResolver);
public abstract Type ResolveName (string typeName, string typeNamespace, Type declaredType, System.Runtime.Serialization.DataContractResolver knownTypeResolver);
abstract member ResolveName : string * string * Type * System.Runtime.Serialization.DataContractResolver -> Type
Public MustOverride Function ResolveName (typeName As String, typeNamespace As String, declaredType As Type, knownTypeResolver As DataContractResolver) As Type

パラメーター

typeName
String

マップする xsi:type 名。The xsi:type name to map.

typeNamespace
String

マップする xsi:type の名前空間。The xsi:type namespace to map.

declaredType
Type

データ コントラクト内で宣言された型。The type declared in the data contract.

knownTypeResolver
DataContractResolver

既知の型リゾルバー。The known type resolver.

戻り値

xsi:type 名および名前空間のマップ先の型。The type the xsi:type name and namespace is mapped to.

ResolveName メソッドを実装する例を次に示します。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;
    }
}

注釈

実装内部の既知の型解決ロジックを使用する場合は、その参照は knownTypeResolver パラメーターとして渡されます。If you want to use the known type resolution logic inside your implementation, a reference to it is passed in as the knownTypeResolver parameter.

適用対象