Esempio n. 1
0
        /// <summary>
        /// Constructs a CompositeType instance, checking for the validity of the given parameters.
        /// The validity constraints are described below for each parameter.
        /// Note that the contents of the three array parameters <paramref name="itemNames"/>,
        /// <paramref name="itemDescriptions"/> and <paramref name="itemTypes"/>  are internally copied so that
        /// any subsequent modification of these arrays by the caller of this constructor has no impact on the
        /// constructed CompositeType instance.
        /// </summary>
        /// <param name="typeName">The name given to the composite type this instance represents; cannot be a
        /// null or empty string.</param>
        /// <param name="description">The human readable description of the composite type this instance
        /// represents; cannot be a null or empty string. </param>
        /// <param name="itemNames">The names of the items contained in the composite data values described by
        /// this CompositeType instance; cannot be null and should contain at least one element; no element can
        /// be a null or empty string. Note that the order in which the item names are given is not important
        /// to differentiate a CompositeType instance from another; the item names are internally stored sorted
        /// in ascending alphanumeric order. </param>
        /// <param name="itemDescriptions">The descriptions, in the same order as <paramref name="itemNames"/>,
        /// of the items contained in the composite data values described by this CompositeType instance; should
        /// be of the same size as itemNames; no element can be a null or empty string. </param>
        /// <param name="itemTypes">The open type instances, in the same order as itemNames, describing the items
        /// contained in the composite data values described by this CompositeType instance; should be of the
        /// same size as <paramref name="itemNames"/>; no element can be null.</param>
        public CompositeType(string typeName, string description, IEnumerable <string> itemNames,
                             IEnumerable <string> itemDescriptions, IEnumerable <OpenType> itemTypes)
            : base(typeof(ICompositeData), typeName, description)
        {
            if (itemNames == null)
            {
                throw new ArgumentNullException("itemNames");
            }
            if (itemDescriptions == null)
            {
                throw new ArgumentNullException("itemDescriptions");
            }
            if (itemTypes == null)
            {
                throw new ArgumentNullException("itemTypes");
            }
            IEnumerator <string>   descriptions = itemDescriptions.GetEnumerator();
            IEnumerator <OpenType> types        = itemTypes.GetEnumerator();

            foreach (string name in itemNames)
            {
                descriptions.MoveNext();
                types.MoveNext();
                if (string.IsNullOrEmpty(name))
                {
                    throw new ArgumentNullException("itemNames", "Item names cannot contain null or empty string items.");
                }
                if (string.IsNullOrEmpty(descriptions.Current))
                {
                    throw new ArgumentNullException("itemDescriptions", "Item descriptions cannot contain null or empty string items.");
                }
                if (types.Current == null)
                {
                    throw new ArgumentNullException("itemTypes", "Item types cannot contain null items.");
                }
                if (_members.ContainsKey(name))
                {
                    throw new OpenDataException("CompositeType items cannot have duplicate keys.");
                }
                _members[name] = new CompositeTypeMember(descriptions.Current, types.Current);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Constructs a CompositeType instance, checking for the validity of the given parameters. 
 /// The validity constraints are described below for each parameter.
 /// Note that the contents of the three array parameters <paramref name="itemNames"/>, 
 /// <paramref name="itemDescriptions"/> and <paramref name="itemTypes"/>  are internally copied so that 
 /// any subsequent modification of these arrays by the caller of this constructor has no impact on the 
 /// constructed CompositeType instance.
 /// </summary>
 /// <param name="typeName">The name given to the composite type this instance represents; cannot be a 
 /// null or empty string.</param>
 /// <param name="description">The human readable description of the composite type this instance 
 /// represents; cannot be a null or empty string. </param>
 /// <param name="itemNames">The names of the items contained in the composite data values described by 
 /// this CompositeType instance; cannot be null and should contain at least one element; no element can 
 /// be a null or empty string. Note that the order in which the item names are given is not important 
 /// to differentiate a CompositeType instance from another; the item names are internally stored sorted 
 /// in ascending alphanumeric order. </param>
 /// <param name="itemDescriptions">The descriptions, in the same order as <paramref name="itemNames"/>, 
 /// of the items contained in the composite data values described by this CompositeType instance; should 
 /// be of the same size as itemNames; no element can be a null or empty string. </param>
 /// <param name="itemTypes">The open type instances, in the same order as itemNames, describing the items 
 /// contained in the composite data values described by this CompositeType instance; should be of the 
 /// same size as <paramref name="itemNames"/>; no element can be null.</param>
 public CompositeType(string typeName, string description, IEnumerable<string> itemNames,
     IEnumerable<string> itemDescriptions, IEnumerable<OpenType> itemTypes)
     : base(typeof(ICompositeData), typeName, description)
 {
     if (itemNames == null)
      {
     throw new ArgumentNullException("itemNames");
      }
      if (itemDescriptions == null)
      {
     throw new ArgumentNullException("itemDescriptions");
      }
      if (itemTypes == null)
      {
     throw new ArgumentNullException("itemTypes");
      }
      IEnumerator<string> descriptions = itemDescriptions.GetEnumerator();
      IEnumerator<OpenType> types = itemTypes.GetEnumerator();
      foreach (string name in itemNames)
      {
     descriptions.MoveNext();
     types.MoveNext();
     if (string.IsNullOrEmpty(name))
     {
        throw new ArgumentNullException("itemNames", "Item names cannot contain null or empty string items.");
     }
     if (string.IsNullOrEmpty(descriptions.Current))
     {
        throw new ArgumentNullException("itemDescriptions", "Item descriptions cannot contain null or empty string items.");
     }
     if (types.Current == null)
     {
        throw new ArgumentNullException("itemTypes", "Item types cannot contain null items.");
     }
     if (_members.ContainsKey(name))
     {
        throw new OpenDataException("CompositeType items cannot have duplicate keys.");
     }
     _members[name] = new CompositeTypeMember(descriptions.Current, types.Current);
      }
 }
Esempio n. 3
0
        public sealed override bool Equals(object obj)
        {
            CompositeType other = obj as CompositeType;

            if (other != null && TypeName.Equals(other.TypeName) && other._members.Count == _members.Count)
            {
                foreach (string key in _members.Keys)
                {
                    CompositeTypeMember thisMember = _members[key];
                    CompositeTypeMember otherMember;
                    if (!other._members.TryGetValue(key, out otherMember))
                    {
                        return(false);
                    }
                    if (!thisMember.Equals(otherMember))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
            public override bool Equals(object obj)
            {
                CompositeTypeMember other = obj as CompositeTypeMember;

                return(other != null && _type.Equals(other._type));
            }