1 /******************************************************************************
3 * Copyright (c) 2003 Novell Inc., www.novell.com
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
22 *******************************************************************************/
25 // System.DirectoryServices.PropertyCollection.cs
28 // Sunil Kumar (sunilk@novell.com)
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
)
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
)
84 void Add(object oKey
, object oValue
)
87 m_oValues
.Add(oKey
, oValue
);
90 void IDictionary
.Add(object oKey
, object 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()
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
]
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()];
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
);
182 // throw new InvalidOperationException();