IDataContractSurrogate.GetReferencedTypeOnImport Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Selama impor skema, mengembalikan jenis yang dirujuk oleh skema.
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
Parameter
- typeName
- String
Nama jenis dalam skema.
- typeNamespace
- String
Namespace jenis dalam skema.
- customData
- Object
Objek yang mewakili anotasi yang disisipkan ke dalam definisi skema XML, yang merupakan data yang dapat digunakan untuk menemukan jenis yang direferensikan.
Mengembalikan
yang Type digunakan untuk jenis yang dirujuk.
Contoh
Contoh berikut menunjukkan implementasi GetReferencedTypeOnImport metode .
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
Keterangan
Null
harus dikembalikan jika jenis CLR tidak ada untuk mewakili jenis skema. Ini akan menyebabkan jenis baru dihasilkan selama impor skema.
Berlaku untuk
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk