コード例 #1
0
ファイル: TypeHelpers.cs プロジェクト: tsasioglu/roslyn
        internal static Type GetInterfaceListEntry(this Type interfaceType, Type declaration)
        {
            Debug.Assert(interfaceType.IsInterface);

            if (!interfaceType.IsGenericType || !declaration.IsGenericType)
            {
                return(interfaceType);
            }

            var index = Array.IndexOf(declaration.GetInterfacesOnType(), interfaceType);

            Debug.Assert(index >= 0);

            var result = declaration.GetGenericTypeDefinition().GetInterfacesOnType()[index];

            Debug.Assert(interfaceType.GetGenericTypeDefinition().Equals(result.GetGenericTypeDefinition()));
            return(result);
        }