Type.GetInterfaceMap(Type) 메서드

정의

지정된 인터페이스 형식에 대한 인터페이스 매핑을 반환합니다.

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

매핑을 검색할 인터페이스의 형식입니다.

반환

InterfaceMapping

interfaceType에 대한 인터페이스 매핑을 나타내는 개체입니다.

구현

특성

예외

interfaceType이 현재 형식에 의해 구현되지 않았습니다.

또는 interfaceType 인수는 인터페이스를 참조하지 않습니다.

또는

현재 인스턴스 또는 interfaceType 인수는 개방형 제네릭 형식입니다. 즉, ContainsGenericParameters 속성은 true를 반환합니다.

또는

interfaceType 은 제네릭 인터페이스이며 현재 형식이 배열 형식입니다.

interfaceType이(가) null인 경우

현재 Type 은 제네릭 형식 매개 변수를 나타내며, 즉 IsGenericParametertrue입니다.

호출된 메서드가 기본 클래스에서 지원되지 않습니다. 파생 클래스에서 구현을 제공해야 합니다.

예제

다음 예제에서는 메서드를 호출 GetInterfaceMap 하 여 IFormatProvider 인터페이스가 메서드에 매핑되는 방식과 CultureInfo 인터페이스를 IAppDomainSetup 속성에 매핑하 AppDomainSetup 는 방법을 결정 합니다. 인터페이스는 속성 집합을 정의 하기 때문에 IAppDomainSetup 반환 되는 개체에는 InterfaceMapping MethodInfo 속성의 get 및 set 접근자에 대 한 별도의 개체가 포함 되어 있습니다.

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
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 .

적용 대상

추가 정보