X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem%2FSystem.Collections.Specialized%2FNameObjectCollectionBase.cs;h=c934a328c053dd2bc49099fedcbb28e6471c9547;hb=c259a8cc51e4240849a68d69db7781df89152213;hp=89f59108dcb62ac6e5046cdaa0c11b95476f1e49;hpb=dbf19eb41dbd299c4c33d4de35ffe3cf6c669832;p=mono.git diff --git a/mcs/class/System/System.Collections.Specialized/NameObjectCollectionBase.cs b/mcs/class/System/System.Collections.Specialized/NameObjectCollectionBase.cs index 89f59108dcb..c934a328c05 100644 --- a/mcs/class/System/System.Collections.Specialized/NameObjectCollectionBase.cs +++ b/mcs/class/System/System.Collections.Specialized/NameObjectCollectionBase.cs @@ -101,7 +101,7 @@ namespace System.Collections.Specialized } public bool MoveNext() { - return ((++m_position) 0) && (arrayIndex >= array.Length)) + throw new ArgumentException ("arrayIndex is equal to or greater than array.Length"); + + if (arrayIndex + items.Count > array.Length) + throw new ArgumentException ("Not enough room from arrayIndex to end of array for this KeysCollection"); +#endif + + if (array != null && array.Rank > 1) + throw new ArgumentException ("array is multidimensional"); + + object[] objArray = (object[])array; + for (int i = 0; i < items.Count; i++, arrayIndex++) + objArray [arrayIndex] = ((_Item)items [i]).key; } bool ICollection.IsSynchronized @@ -209,27 +221,33 @@ namespace System.Collections.Specialized #endif m_defCapacity = capacity; Init(); - } + } #if NET_2_0 - protected NameObjectCollectionBase (IEqualityComparer equalityComparer) + + internal NameObjectCollectionBase (IEqualityComparer equalityComparer, IComparer comparer, IHashCodeProvider hcp) { - m_readonly = false; equality_comparer = equalityComparer; + m_comparer = comparer; + m_hashprovider = hcp; + m_readonly = false; m_defCapacity = 0; - Init(); + Init (); } + protected NameObjectCollectionBase (IEqualityComparer equalityComparer) : this( (equalityComparer == null ? StringComparer.InvariantCultureIgnoreCase : equalityComparer), null, null) + { + } + [Obsolete ("Use NameObjectCollectionBase(IEqualityComparer)")] #endif protected NameObjectCollectionBase( IHashCodeProvider hashProvider, IComparer comparer ) - { - m_readonly = false; - - m_hashprovider = hashProvider; + { m_comparer = comparer; + m_hashprovider = hashProvider; + m_readonly = false; m_defCapacity = 0; - Init(); + Init (); } protected NameObjectCollectionBase (SerializationInfo info, StreamingContext context) @@ -241,7 +259,7 @@ namespace System.Collections.Specialized protected NameObjectCollectionBase (int capacity, IEqualityComparer equalityComparer) { m_readonly = false; - equality_comparer = equalityComparer; + equality_comparer = (equalityComparer == null ? StringComparer.InvariantCultureIgnoreCase : equalityComparer); m_defCapacity = capacity; Init(); } @@ -354,7 +372,7 @@ namespace System.Collections.Specialized void ICollection.CopyTo (Array array, int index) { - (Keys as ICollection).CopyTo (array, index); + ((ICollection)Keys).CopyTo (array, index); } // IDeserializationCallback @@ -568,7 +586,6 @@ namespace System.Collections.Specialized /// It's ok only then the key is uniquely assosiated with the value /// To fix it a comparsion of objects stored under the same key in the hashtable and in the arraylist should be added /// > - [MonoTODO] protected void BaseRemoveAt( int index ) { if (this.IsReadOnly) @@ -590,8 +607,10 @@ namespace System.Collections.Specialized /// protected void BaseSet( int index, object value ) { +#if NET_2_0 if (this.IsReadOnly) throw new NotSupportedException("Collection is read-only"); +#endif _Item item = (_Item)m_ItemsArray[index]; item.value = value; } @@ -603,8 +622,10 @@ namespace System.Collections.Specialized /// The Object that represents the new value of the entry to set. The value can be a null reference protected void BaseSet( string name, object value ) { +#if NET_2_0 if (this.IsReadOnly) throw new NotSupportedException("Collection is read-only"); +#endif _Item item = FindFirstMatchedItem(name); if (item!=null) item.value=value;