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 *******************************************************************************/
24 // Novell.Directory.Ldap.Utilclass.RespControlVector.cs
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
34 namespace Novell.Directory.Ldap.Utilclass
37 /// <summary> The <code>MessageVector</code> class implements extends the
38 /// existing Vector class so that it can be used to maintain a
39 /// list of currently registered control responses.
41 public class RespControlVector:System.Collections.ArrayList
43 public RespControlVector(int cap, int incr):base(cap)
48 /// <summary>Inner class defined to create a temporary object to encapsulate
49 /// all registration information about a response control. This class
50 /// cannot be used outside this class
52 private class RegisteredControl
54 private void InitBlock(RespControlVector enclosingInstance)
56 this.enclosingInstance = enclosingInstance;
58 private RespControlVector enclosingInstance;
59 public RespControlVector Enclosing_Instance
63 return enclosingInstance;
67 public System.String myOID;
68 public System.Type myClass;
70 public RegisteredControl(RespControlVector enclosingInstance, System.String oid, System.Type controlClass)
72 InitBlock(enclosingInstance);
74 myClass = controlClass;
78 /* Adds a control to the current list of registered response controls.
81 public void registerResponseControl(System.String oid, System.Type controlClass)
86 Add(new RegisteredControl(this, oid, controlClass));
90 /* Searches the list of registered controls for a mathcing control. We
91 * search using the OID string. If a match is found we return the
92 * Class name that was provided to us on registration.
94 public System.Type findResponseControl(System.String searchOID)
98 RegisteredControl ctl = null;
100 /* loop through the contents of the vector */
101 for (int i = 0; i < Count; i++)
104 /* Get next registered control */
105 if ((ctl = (RegisteredControl) this[i]) == null)
107 throw new System.FieldAccessException();
110 /* Does the stored OID match with whate we are looking for */
111 if (ctl.myOID.CompareTo(searchOID) == 0)
115 /* Return the class name if we have match */
119 /* The requested control does not have a registered response class */