コード例 #1
0
ファイル: TypeBuilder.cs プロジェクト: avensia-oss/tstypegen
        private static Type GetEnumerableUnderlyingType(Type type)
        {
            var types = type.GetInterfaces().ToList();

            types.Add(type);
            var enumerable = types.FirstOrDefault(i => i.IsGenericType && TypeUtils.Equals(typeof(IEnumerable <>), i.GetGenericTypeDefinition()));

            if (enumerable != null)
            {
                return(enumerable.GenericTypeArguments.FirstOrDefault());
            }

            return(null);
        }
コード例 #2
0
ファイル: TypeBuilder.cs プロジェクト: avensia-oss/tstypegen
 private static bool IsDictionaryInterface(Type type)
 {
     return(type.IsGenericType && (TypeUtils.Equals(type.GetGenericTypeDefinition(), typeof(IDictionary <,>)) || TypeUtils.Equals(type.GetGenericTypeDefinition(), typeof(IReadOnlyDictionary <,>))));
 }