Share via


IDataContractSurrogate.GetReferencedTypeOnImport 메서드

정의

스키마 가져오기 중에 스키마가 참조하는 형식을 반환합니다.

public:
 Type ^ GetReferencedTypeOnImport(System::String ^ typeName, System::String ^ typeNamespace, System::Object ^ customData);
public Type GetReferencedTypeOnImport (string typeName, string typeNamespace, object customData);
abstract member GetReferencedTypeOnImport : string * string * obj -> Type
Public Function GetReferencedTypeOnImport (typeName As String, typeNamespace As String, customData As Object) As Type

매개 변수

typeName
String

스키마에 있는 형식의 이름입니다.

typeNamespace
String

스키마에 있는 형식의 네임스페이스입니다.

customData
Object

XML 스키마 정의에 삽입된 주석을 나타내는 개체로, 참조된 형식을 찾을 때 사용할 수 있는 데이터입니다.

반환

참조된 형식에 사용할 Type입니다.

예제

다음 예제에서는 GetReferencedTypeOnImport 메서드의 구현을 보여 줍니다.

public Type GetReferencedTypeOnImport(string typeName,
    string typeNamespace, object customData)
{
    Console.WriteLine("GetReferencedTypeOnImport invoked");
    // This method is called on schema import.
    // If a PersonSurrogated data contract is
    // in the specified namespace, do not create a new type for it
    // because there is already an existing type, "Person".
    Console.WriteLine( "\t Type Name: {0}", typeName);

    if (typeName.Equals("PersonSurrogated") )
    {
        Console.WriteLine("Returning Person");
        return typeof(Person);
    }
    return null;
}
Public Function GetReferencedTypeOnImport(ByVal typeName As String, _
    ByVal typeNamespace As String, ByVal customData As Object) As Type _
    Implements IDataContractSurrogate.GetReferencedTypeOnImport
    Console.WriteLine("GetReferencedTypeOnImport invoked")
    ' This method is called on schema import.
    ' If a PersonSurrogated data contract is 
    ' in the specified namespace, do not create a new type for it 
    ' because there is already an existing type, "Person".
    Console.WriteLine(vbTab & "Type Name: {0}", typeName)

    'If typeNamespace.Equals("http://schemas.datacontract.org/2004/07/DCSurrogateSample") Then
    If typeName.Equals("PersonSurrogated") Then
        Console.WriteLine("Returning Person")
        Return GetType(Person)
    End If
    'End If
    Return Nothing

End Function

설명

Null 는 스키마 형식을 나타내는 CLR 형식이 없는 경우 반환되어야 합니다. 이렇게 하면 스키마를 가져오는 동안 새 형식이 생성됩니다.

적용 대상