Novell.Directory.Ldap.LdapControl.Clone C# (CSharp) Method

Clone() public method

Returns a copy of the current LdapControl object.
public Clone ( ) : Object
return System.Object
        public System.Object Clone()
        {
            LdapControl cont;
            try
            {
                cont = (LdapControl) base.MemberwiseClone();
            }
            catch (System.Exception ce)
            {
                throw new System.SystemException("Internal error, cannot create clone");
            }
            sbyte[] vals = this.getValue();
            sbyte[] twin = null;
            if (vals != null)
            {
                //is this necessary?
                // Yes even though the contructor above allocates a
                // new Asn1OctetString, vals in that constuctor
                // is only copied by reference
                twin = new sbyte[vals.Length];
                for (int i = 0; i < vals.Length; i++)
                {
                    twin[i] = vals[i];
                }
                cont.control = new RfcControl(new RfcLdapOID(ID), new Asn1Boolean(Critical), new Asn1OctetString(twin));
            }
            return cont;
        }

Usage Example

示例#1
0
 /// <summary> Sets a single control to be sent to the server.
 ///
 /// </summary>
 /// <param name="control">    A single control to be sent to the server or
 /// null if none.
 /// </param>
 public virtual void setControls(LdapControl control)
 {
     if (control == null)
     {
         this.controls = null;
         return;
     }
     this.controls    = new LdapControl[1];
     this.controls[0] = (LdapControl)control.Clone();
 }
All Usage Examples Of Novell.Directory.Ldap.LdapControl::Clone