Type.GetInterfaceMap(Type) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 인터페이스 형식에 대한 인터페이스 매핑을 반환합니다.
public:
virtual System::Reflection::InterfaceMapping GetInterfaceMap(Type ^ interfaceType);
public virtual System.Reflection.InterfaceMapping GetInterfaceMap(Type interfaceType);
[System.Runtime.InteropServices.ComVisible(true)]
public virtual System.Reflection.InterfaceMapping GetInterfaceMap(Type interfaceType);
abstract member GetInterfaceMap : Type -> System.Reflection.InterfaceMapping
override this.GetInterfaceMap : Type -> System.Reflection.InterfaceMapping
[<System.Runtime.InteropServices.ComVisible(true)>]
abstract member GetInterfaceMap : Type -> System.Reflection.InterfaceMapping
override this.GetInterfaceMap : Type -> System.Reflection.InterfaceMapping
Public Overridable Function GetInterfaceMap (interfaceType As Type) As InterfaceMapping
매개 변수
- interfaceType
- Type
매핑을 검색할 인터페이스 형식입니다.
반품
에 대한 인터페이스 매핑을 나타내는 개체입니다 interfaceType.
구현
- 특성
예외
interfaceType 은 현재 형식으로 구현되지 않습니다.
-또는-
인수는 interfaceType 인터페이스를 참조하지 않습니다.
-또는-
현재 인스턴스 또는 interfaceType 인수는 열린 제네릭 형식입니다. 즉, 속성이 ContainsGenericParameters 반환됩니다 true.
-또는-
interfaceType 는 제네릭 인터페이스이고 현재 형식은 배열 형식입니다.
interfaceType은 null입니다.
현재 Type 는 제네릭 형식 매개 변수, IsGenericParametertrue즉 .
호출된 메서드는 기본 클래스에서 지원되지 않습니다. 파생 클래스는 구현을 제공해야 합니다.
예제
다음 예제에서는 메서드를 GetInterfaceMap 호출하여 인터페이스가 메서드에 IFormatProvider 매핑하는 CultureInfo 방법과 인터페이스가 속성에 IAppDomainSetup 매핑하는 방법을 결정합니다 AppDomainSetup . 인터페이스는 IAppDomainSetup 속성 집합을 정의하기 때문에 반환된 InterfaceMapping 개체에는 속성의 get 및 set 접근자에 대한 별도의 MethodInfo 개체가 포함됩니다.
using System;
using System.Globalization;
using System.Reflection;
public class Example
{
public static void Main()
{
Type[] interf = { typeof(IFormatProvider), typeof(IAppDomainSetup) };
Type[] impl = { typeof(CultureInfo), typeof(AppDomainSetup) };
for (int ctr = 0; ctr < interf.Length; ctr++)
ShowInterfaceMapping(interf[ctr], impl[ctr]);
}
private static void ShowInterfaceMapping(Type intType, Type implType)
{
InterfaceMapping map = implType.GetInterfaceMap(intType);
Console.WriteLine("Mapping of {0} to {1}: ", map.InterfaceType, map.TargetType);
for (int ctr = 0; ctr < map.InterfaceMethods.Length; ctr++) {
MethodInfo im = map.InterfaceMethods[ctr];
MethodInfo tm = map.TargetMethods[ctr];
Console.WriteLine(" {0} --> {1}", im.Name,tm.Name);
}
Console.WriteLine();
}
}
// The example displays the following output:
// Mapping of System.IFormatProvider to System.Globalization.CultureInfo:
// GetFormat --> GetFormat
//
// Mapping of System.IAppDomainSetup to System.AppDomainSetup:
// get_ApplicationBase --> get_ApplicationBase
// set_ApplicationBase --> set_ApplicationBase
// get_ApplicationName --> get_ApplicationName
// set_ApplicationName --> set_ApplicationName
// get_CachePath --> get_CachePath
// set_CachePath --> set_CachePath
// get_ConfigurationFile --> get_ConfigurationFile
// set_ConfigurationFile --> set_ConfigurationFile
// get_DynamicBase --> get_DynamicBase
// set_DynamicBase --> set_DynamicBase
// get_LicenseFile --> get_LicenseFile
// set_LicenseFile --> set_LicenseFile
// get_PrivateBinPath --> get_PrivateBinPath
// set_PrivateBinPath --> set_PrivateBinPath
// get_PrivateBinPathProbe --> get_PrivateBinPathProbe
// set_PrivateBinPathProbe --> set_PrivateBinPathProbe
// get_ShadowCopyDirectories --> get_ShadowCopyDirectories
// set_ShadowCopyDirectories --> set_ShadowCopyDirectories
// get_ShadowCopyFiles --> get_ShadowCopyFiles
// set_ShadowCopyFiles --> set_ShadowCopyFiles
open System
open System.Globalization
let showInterfaceMapping (intType: Type) (implType: Type) =
let map = implType.GetInterfaceMap intType
printfn $"Mapping of {map.InterfaceType} to {map.TargetType}: "
for i = 0 to map.InterfaceMethods.Length - 1 do
let im = map.InterfaceMethods[i]
let tm = map.TargetMethods[i]
printfn $" {im.Name} --> {tm.Name}"
printfn ""
let interf = [| typeof<IFormatProvider>; typeof<IAppDomainSetup> |]
let impl = [| typeof<CultureInfo>; typeof<AppDomainSetup> |]
for i = 0 to interf.Length - 1 do
showInterfaceMapping interf[i] impl[i]
// The example displays the following output:
// Mapping of System.IFormatProvider to System.Globalization.CultureInfo:
// GetFormat --> GetFormat
//
// Mapping of System.IAppDomainSetup to System.AppDomainSetup:
// get_ApplicationBase --> get_ApplicationBase
// set_ApplicationBase --> set_ApplicationBase
// get_ApplicationName --> get_ApplicationName
// set_ApplicationName --> set_ApplicationName
// get_CachePath --> get_CachePath
// set_CachePath --> set_CachePath
// get_ConfigurationFile --> get_ConfigurationFile
// set_ConfigurationFile --> set_ConfigurationFile
// get_DynamicBase --> get_DynamicBase
// set_DynamicBase --> set_DynamicBase
// get_LicenseFile --> get_LicenseFile
// set_LicenseFile --> set_LicenseFile
// get_PrivateBinPath --> get_PrivateBinPath
// set_PrivateBinPath --> set_PrivateBinPath
// get_PrivateBinPathProbe --> get_PrivateBinPathProbe
// set_PrivateBinPathProbe --> set_PrivateBinPathProbe
// get_ShadowCopyDirectories --> get_ShadowCopyDirectories
// set_ShadowCopyDirectories --> set_ShadowCopyDirectories
// get_ShadowCopyFiles --> get_ShadowCopyFiles
// set_ShadowCopyFiles --> set_ShadowCopyFiles
Imports System.Globalization
Imports System.Reflection
Module Example
Public Sub Main()
Dim int() As Type = { GetType(IFormatProvider), GetType(IAppDomainSetup) }
Dim impl() As Type = { GetType(CultureInfo), GetType(AppDomainSetup) }
For ctr As Integer = 0 To int.Length - 1
ShowInterfaceMapping(int(ctr), impl(ctr))
Next
End Sub
Private Sub ShowInterfaceMapping(intType As Type, implType As Type)
Dim map As InterfaceMapping = implType.GetInterfaceMap(intType)
Console.WriteLine("Mapping of {0} to {1}: ", map.InterfaceType, map.TargetType)
For ctr As Integer = 0 To map.InterfaceMethods.Length - 1
Dim im As MethodInfo = map.InterfaceMethods(ctr)
Dim tm As MethodInfo = map.TargetMethods(ctr)
Console.WriteLine(" {0} --> {1}", im.Name,tm.Name)
Next
Console.WriteLine()
End Sub
End Module
' The example displays the following output:
' Mapping of System.IFormatProvider to System.Globalization.CultureInfo:
' GetFormat --> GetFormat
'
' Mapping of System.IAppDomainSetup to System.AppDomainSetup:
' get_ApplicationBase --> get_ApplicationBase
' set_ApplicationBase --> set_ApplicationBase
' get_ApplicationName --> get_ApplicationName
' set_ApplicationName --> set_ApplicationName
' get_CachePath --> get_CachePath
' set_CachePath --> set_CachePath
' get_ConfigurationFile --> get_ConfigurationFile
' set_ConfigurationFile --> set_ConfigurationFile
' get_DynamicBase --> get_DynamicBase
' set_DynamicBase --> set_DynamicBase
' get_LicenseFile --> get_LicenseFile
' set_LicenseFile --> set_LicenseFile
' get_PrivateBinPath --> get_PrivateBinPath
' set_PrivateBinPath --> set_PrivateBinPath
' get_PrivateBinPathProbe --> get_PrivateBinPathProbe
' set_PrivateBinPathProbe --> set_PrivateBinPathProbe
' get_ShadowCopyDirectories --> get_ShadowCopyDirectories
' set_ShadowCopyDirectories --> set_ShadowCopyDirectories
' get_ShadowCopyFiles --> get_ShadowCopyFiles
' set_ShadowCopyFiles --> set_ShadowCopyFiles
설명
인터페이스 맵은 인터페이스가 해당 인터페이스를 구현하는 클래스의 실제 멤버에 매핑되는 방법을 나타냅니다.
현재 Type 가 생성된 제네릭 형식을 나타내는 경우 형식 매개 변수는 이 메서드에서 반환된 요소의 InterfaceMapping 적절한 형식 인수로 대체됩니다.