コード例 #1
0
        static bool IsValidFieldOfType(this IDeclaredElement element, Type type)
        {
            IDeclaredType fieldType = element.GetValidatedFieldType();

            if (fieldType == null)
            {
                return(false);
            }

            return(new CLRTypeName(fieldType.GetCLRName()) == new CLRTypeName(type.FullName));
        }
コード例 #2
0
        static bool IsValidFieldOfType(this IDeclaredElement element, string typeFullName)
        {
            IDeclaredType fieldType = element.GetValidatedFieldType();

            if (fieldType == null)
            {
                return(false);
            }

            return(fieldType.GetTypeElement().HasAttributeInstance(new ClrTypeName(typeFullName), false));
        }
コード例 #3
0
        static bool IsValidFieldOfType(this IDeclaredElement element, Type type)
        {
            IDeclaredType fieldType = element.GetValidatedFieldType();

            if (fieldType == null)
            {
                return(false);
            }

#if RESHARPER_6
            return(fieldType.GetClrName().FullName == type.FullName);
#else
            return(new CLRTypeName(fieldType.GetCLRName()) == new CLRTypeName(type.FullName));
#endif
        }
コード例 #4
0
        public static IClass GetFirstGenericArgument(this IDeclaredElement element)
        {
            IDeclaredType fieldType = element.GetValidatedFieldType();

            if (fieldType == null)
            {
                return(null);
            }

            var firstArgument  = fieldType.GetSubstitution().Domain.First();
            var referencedType = fieldType.GetSubstitution().Apply(firstArgument).GetScalarType();

            if (referencedType != null)
            {
                return(referencedType.GetTypeElement() as IClass);
            }

            return(null);
        }