示例#1
0
        /// <summary>
        /// Gets whether the specified type is a nullable type.
        /// </summary>
        public static bool IsNullable(IType type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            ParameterizedTypeSpec pt = type as ParameterizedTypeSpec;

            return(pt != null && pt.TypeParameterCount == 1 && pt.GetDefinition().KnownTypeCode == KnownTypeCode.NullableOfT);
        }
示例#2
0
        /// <summary>
        /// Returns the element type, if <paramref name="type"/> is a nullable type.
        /// Otherwise, returns the type itself.
        /// </summary>
        public static IType GetUnderlyingType(IType type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            ParameterizedTypeSpec pt = type as ParameterizedTypeSpec;

            if (pt != null && pt.TypeParameterCount == 1 && pt.FullName == "Std.Nullable")
            {
                return(pt.GetTypeArgument(0));
            }
            else
            {
                return(type);
            }
        }
        public bool Equals(IType other)
        {
            ParameterizedTypeSpec c = other as ParameterizedTypeSpec;

            if (c == null || !genericType.Equals(c.genericType) || typeArguments.Length != c.typeArguments.Length)
            {
                return(false);
            }
            for (int i = 0; i < typeArguments.Length; i++)
            {
                if (!typeArguments[i].Equals(c.typeArguments[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
示例#4
0
 public virtual IType VisitParameterizedType(ParameterizedTypeSpec type)
 {
     return(type.VisitChildren(this));
 }