static LdapControl() { RegisteredControls = new RespControlVector(); }
/// <summary> Instantiates an LdapControl. We search through our list of /// registered controls. If we find a matchiing OID we instantiate /// that control by calling its contructor. Otherwise we default to /// returning a regular LdapControl object /// /// </summary> private LdapControl controlFactory(System.String oid, bool critical, sbyte[] value_Renamed) { // throw new NotImplementedException(); RespControlVector regControls = LdapControl.RegisteredControls; try { /* * search through the registered extension list to find the * response control class */ System.Type respCtlClass = regControls.findResponseControl(oid); // Did not find a match so return default LDAPControl if (respCtlClass == null) { return(new LdapControl(oid, critical, value_Renamed)); } /* If found, get LDAPControl constructor */ System.Type[] argsClass = new System.Type[] { typeof(System.String), typeof(bool), typeof(sbyte[]) }; System.Object[] args = new System.Object[] { oid, critical, value_Renamed }; System.Exception ex = null; try { System.Reflection.ConstructorInfo ctlConstructor = respCtlClass.GetConstructor(argsClass); try { /* Call the control constructor for a registered Class*/ System.Object ctl = null; // ctl = ctlConstructor.newInstance(args); ctl = ctlConstructor.Invoke(args); return((LdapControl)ctl); } catch (System.UnauthorizedAccessException e) { ex = e; } catch (System.Reflection.TargetInvocationException e) { ex = e; } catch (System.Exception e) { // Could not create the ResponseControl object // All possible exceptions are ignored. We fall through // and create a default LDAPControl object ex = e; } } catch (System.MethodAccessException e) { // bad class was specified, fall through and return a // default LDAPControl object ex = e; } } catch (System.FieldAccessException e) { // No match with the OID // Do nothing. Fall through and construct a default LDAPControl object. } // If we get here we did not have a registered response control // for this oid. Return a default LDAPControl object. return(new LdapControl(oid, critical, value_Renamed)); }
static LdapControl() { registeredControls = new RespControlVector(5, 5); }