Merge pull request #4453 from lambdageek/bug-49721
[mono.git] / mcs / class / System.DirectoryServices / System.DirectoryServices / ResultPropertyCollection.cs
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:
11
12 * The above copyright notice and this permission notice shall be included in 
13 * all copies or substantial portions of the Software.
14
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 *******************************************************************************/
23
24 //
25 // System.DirectoryServices.ResultPropertyCollection .cs
26 //
27 // Author:
28 //   Sunil Kumar (sunilk@novell.com)
29 //
30 // (C)  Novell Inc.
31 //
32
33 using System;
34 using System.Collections;
35
36 namespace System.DirectoryServices
37 {
38         /// <summary>
39         /// Contains the properties of a SearchResult instance. 
40         /// 
41         /// For a list of all members of this type, see ResultPropertyCollection 
42         /// Members.
43         /// </summary>
44         /// <remarks>
45         /// SearchResult instances are similar to DirectoryEntry instances. The 
46         /// notable difference is that the DirectoryEntry retrieves its 
47         /// information from the Active Directory hierarchy each time a new object 
48         /// is accessed, whereas the data for the SearchResult is already 
49         /// available in the SearchResultCollection that a DirectorySearcher 
50         /// query returns. If you try to get a SearchResult property that your 
51         /// query did not specify for retrieval, the property will not be 
52         /// available.
53         /// </remarks>
54         public class ResultPropertyCollection  : DictionaryBase
55         {
56                 internal ResultPropertyCollection()
57                 {
58                         
59                 }
60
61                 public ResultPropertyValueCollection this[string name]
62                 {
63                         get {
64                                 return (ResultPropertyValueCollection) this.Dictionary[name.ToLower()];
65                         }
66 //                      set { this.Dictionary[key] = value; } 
67                 }
68                 //add a ResultPropertyValueCollection based on key 
69                 internal void Add(string key, ResultPropertyValueCollection rpcoll) 
70                 { 
71                         this.Dictionary.Add(key.ToLower(), rpcoll); 
72                 } 
73                 
74                 //see if collection contains an entry corresponding to key
75                 public bool Contains(string propertyName)
76                 {
77                         return this.Dictionary.Contains(propertyName.ToLower());
78                 }
79                 
80                 public ICollection PropertyNames 
81                 {
82                         get
83                         {
84                                 return this.Dictionary.Keys;
85                         }
86                 }
87
88                 public ICollection Values 
89                 {
90                         get
91                         {
92                                 return this.Dictionary.Values;
93                         }
94                 }
95
96                 public void CopyTo (ResultPropertyValueCollection[] array, int index)
97                 {
98                         foreach (ResultPropertyValueCollection vals in Values)
99                                 array[index++] = vals;
100                 }
101         }
102 }