Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public virtual IType VisitParameterizedType(ParameterizedTypeSpec type)
 {
     return(type.VisitChildren(this));
 }