/// <summary> /// Initializes a new instance of the <see cref="IndexerProviderAttribute"/> class. /// </summary> /// <param name="providerType">The <see cref="Type"/> of the object to be iterated over</param> /// <param name="indexType">The <see cref="Type"/> of the index used by <paramref name="providerType"/>.</param> /// <param name="first">The first index value.</param> /// <param name="last">The last index value.</param> /// <param name="iteratorType">The <see cref="Type"/> of the iterator being used to iterate over <paramref name="providerType"/>.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="indexType"/>, <paramref name="iteratorType"/>, <paramref name="first"/>, /// or <paramref name="last"/> are null.</exception> /// <exception cref="ArgumentException">Thrown if <paramref name="providerType"/> does not have an index of type <paramref name="indexType"/></exception> /// <exception cref="ArgumentException">Thrown in <paramref name="first"/> or <paramref name="last"/> are not of type <paramref name="indexType"/></exception> public IndexerProviderAttribute( Type providerType, Type indexType, Object first, Object last, Type iteratorType ) : base(providerType) { if (indexType == null) { throw new ArgumentNullException("indexType"); } if (iteratorType == null) { throw new ArgumentNullException("iteratorType"); } if (!TypeHelper.HasIndexer(this.ProviderType, indexType)) { throw new ArgumentException( providerType.Name + " does not have an indexer with index of type " + indexType.Name, "indexType"); } if (first == null) { throw new ArgumentNullException("first"); } if (last == null) { throw new ArgumentNullException("last"); } if (first.GetType() != indexType) { throw new ArgumentException("first type does not match indexType"); } if (last.GetType() != indexType) { throw new ArgumentException("first type does not match indexType"); } this.indexType = indexType; this.first = first; this.last = last; this.iteratorType = iteratorType; this.iterator = (IBidirectionalIterator)TypeHelper.CreateInstance(this.iteratorType); }
/// <summary> /// Default constructor - initializes all fields to default values /// </summary> public IndexerProviderAttribute( Type providerType, Type indexType, Object first, Object last, Type iteratorType ) : base(providerType) { if (indexType==null) throw new ArgumentNullException("indexType"); if (iteratorType==null) throw new ArgumentNullException("iteratorType"); if (!TypeHelper.HasIndexer(this.ProviderType,indexType)) throw new ArgumentException( providerType.Name + " does not have an indexer with index of type " + indexType.Name, "indexType"); if (first==null) throw new ArgumentNullException("first"); if (last==null) throw new ArgumentNullException("last"); if (first.GetType()!=indexType) throw new ArgumentException("first type does not match indexType"); if (last.GetType()!=indexType) throw new ArgumentException("first type does not match indexType"); this.indexType = indexType; this.first = first; this.last = last; this.iteratorType = iteratorType; this.iterator = (IBidirectionalIterator)TypeHelper.CreateInstance(this.iteratorType); }