示例#1
0
 /// <summary>
 /// Creates a structurally equivalent collection type from a given type.
 /// </summary>
 /// <param name="type">The type to copy the structure of.</param>
 /// <returns>A structurally equivalent copy of the given type.</returns>
 public static IStonCollectionType Copy(IStonCollectionType type)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     return(new StonCollectionType(type));
 }
示例#2
0
 /// <summary>
 /// Checks the validity of a given STON collection type.
 /// </summary>
 /// <param name="type">The type to check the validity of.</param>
 public static void ValidateType(IStonCollectionType type)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     if (type.ElementType == null)
     {
         throw new StonException("A collection type cannot have a non-existing element type.");
     }
 }
示例#3
0
        /// <summary>
        /// Returns a hash code for a given collection type.
        /// </summary>
        /// <param name="obj">The collection type to get a hash code of.</param>
        /// <returns>The hash code for the type.</returns>
        public int GetHashCode(IStonCollectionType obj)
        {
            if (obj == null)
            {
                return(0);
            }

            int result = GetHashCode(obj.ElementType);

            return((result << 7) ^ (result >> 25) ^ 0x12345678);
        }
示例#4
0
 // writes a colleciton type
 private void WriteType(StonTokenWriter writer, IStonCollectionType type)
 {
     if (type.ElementType is IStonUnionType)
     {
         writer.Write('<');
     }
     WriteType(writer, type.ElementType);
     if (type.ElementType is IStonUnionType)
     {
         writer.Write('>');
     }
     writer.Write("[]");
 }
示例#5
0
        /// <summary>
        /// Determines whether two collection types are equivalent.
        /// </summary>
        /// <param name="x">The first collection type to compare.</param>
        /// <param name="y">The second collection type to compare.</param>
        /// <returns>True when types are equivalent, false otherwise.</returns>
        public bool Equals(IStonCollectionType x, IStonCollectionType y)
        {
            if (x == y)
            {
                return(true);
            }
            else if (x == null || y == null)
            {
                return(false);
            }

            return(Equals(x.ElementType, y.ElementType));
        }
示例#6
0
 /// <summary>
 /// Creates a structurally equivalent collection type from a given type.
 /// </summary>
 /// <param name="type">The type to copy the structure of.</param>
 public StonCollectionType(IStonCollectionType type)
     : this(type.ElementType)
 {
 }