fix typo
[mcs.git] / class / System.DirectoryServices / System.DirectoryServices / PropertyCollection.cs
blobb2ad5e96b79d8ef12ed9a2639f271346b5abb9bd
1 /******************************************************************************
2 * The MIT License
3 * Copyright (c) 2003 Novell Inc., www.novell.com
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the Software), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *******************************************************************************/
25 // System.DirectoryServices.PropertyCollection.cs
27 // Author:
28 // Sunil Kumar (sunilk@novell.com)
30 // (C) Novell Inc.
33 using System;
34 using System.Collections;
35 using System.Globalization;
37 namespace System.DirectoryServices
39 public class PropertyCollection : IDictionary, ICollection,IEnumerable
41 private ArrayList m_oKeys = new ArrayList();
42 private Hashtable m_oValues = new Hashtable();
43 private DirectoryEntry _parent;
45 internal PropertyCollection(): this(null)
49 internal PropertyCollection(DirectoryEntry parent)
51 _parent=parent;
54 public int Count
56 get{return m_oValues.Count;}
59 bool ICollection.IsSynchronized
61 get{return m_oValues.IsSynchronized;}
64 object ICollection.SyncRoot
66 get{return m_oValues.SyncRoot;}
69 void ICopyTo(System.Array oArray, int iArrayIndex)
71 m_oValues.CopyTo(oArray, iArrayIndex);
74 void ICollection.CopyTo(System.Array oArray, int iArrayIndex)
76 ICopyTo(oArray,iArrayIndex);
79 public void CopyTo(PropertyValueCollection[] array, int index)
81 ICopyTo(array,index);
84 void Add(object oKey, object oValue)
86 m_oKeys.Add(oKey);
87 m_oValues.Add(oKey, oValue);
90 void IDictionary.Add(object oKey, object oValue){
91 Add(oKey,oValue);
94 bool IDictionary.IsFixedSize
96 get{return m_oKeys.IsFixedSize;}
99 bool IDictionary.IsReadOnly
101 get{return m_oKeys.IsReadOnly;}
104 ICollection IDictionary.Keys
106 get{return m_oValues.Keys;}
109 public ICollection PropertyNames
111 get{return m_oValues.Keys;}
114 void IDictionary.Clear()
116 m_oValues.Clear();
117 m_oKeys.Clear();
120 bool IContains(object oKey)
122 return m_oValues.Contains(oKey);
124 bool IDictionary.Contains(object oKey)
126 return IContains(oKey);
129 public bool Contains (string propertyName)
131 // String tstr=new String(propertyName.ToCharArray());
132 // return IContains(tstr.ToLower());
133 return IContains(propertyName.ToLower());
137 public IDictionaryEnumerator GetEnumerator()
139 return m_oValues.GetEnumerator();
142 void IDictionary.Remove(object oKey)
144 m_oValues.Remove(oKey);
145 m_oKeys.Remove(oKey);
148 object IDictionary.this[object oKey]
150 get{return m_oValues[oKey];}
151 set{m_oValues[oKey] = value;}
154 public ICollection Values
156 get{return m_oValues.Values;}
159 IEnumerator IEnumerable.GetEnumerator()
161 return m_oValues.GetEnumerator();
164 public PropertyValueCollection this[string propertyName]
166 get
168 if(Contains(propertyName))
170 // String tstr=new String(propertyName.ToCharArray());
171 // return (PropertyValueCollection)m_oValues[tstr.ToLower()];
172 return (PropertyValueCollection)m_oValues[propertyName.ToLower()];
174 else
176 PropertyValueCollection _pValColl=new PropertyValueCollection(_parent);
177 // String tstr=new String(propertyName.ToCharArray());
178 // Add((string)tstr.ToLower(), (PropertyValueCollection)_pValColl);
179 Add((string)propertyName.ToLower(), (PropertyValueCollection)_pValColl);
180 return _pValColl;
182 // throw new InvalidOperationException();