Merge branch 'master' of http://github.com/mono/mono
[mono.git] / mcs / class / System.DirectoryServices / System.DirectoryServices / DirectoryEntry.cs
index 1f6a4f2ff7bd5b89f82863c8f28afc8e6a046ef5..a1dffa258ff47f44fed1a2a93712ef84a6c9ee61 100644 (file)
@@ -39,6 +39,7 @@ using System.Globalization;
 using System.DirectoryServices.Design;
 using System.Collections.Specialized;
 using System.Configuration;
+using System.Runtime.InteropServices;
 
 namespace System.DirectoryServices
 {
@@ -945,6 +946,41 @@ namespace System.DirectoryServices
                        throw new NotImplementedException();
                }
 
+#if NET_2_0
+               /// <summary>
+               /// Gets a property value from the native Active Directory Entry.
+               /// </summary>
+               /// <param name="propertyName">The name of the property to get. 
+               /// </param>
+               /// <returns>The value of the property</returns>
+               /// <remarks>
+               /// Not implemented yet.
+               [ComVisibleAttribute (false)]
+               [MonoNotSupported ("")]
+               public object InvokeGet (string propertyName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               /// <summary>
+               /// Sets a property value on the native Active Directory Entry.
+               /// </summary>
+               /// <param name="propertyName">The name of the property to get. 
+               /// </param>
+               /// <param name="args">
+               /// An array of type Object that contains the arguments of the property 
+               /// beeing set. 
+               /// </param>
+               /// <remarks>
+               /// Not implemented yet.
+               [ComVisibleAttribute (false)]
+               [MonoNotSupported ("")]
+               public void InvokeSet (string propertyName, params object [] args)
+               {
+                       throw new NotImplementedException ();
+               }
+#endif
+
                /// <summary>
                /// Creates a copy of this entry, as a child of the specified parent, with 
                /// the specified new name.
@@ -989,26 +1025,31 @@ namespace System.DirectoryServices
                                        LdapAttribute attr=null;
                                        if (properties [attribute].Mbit)
                                        {
-                                               if (properties [attribute].Count == 1)
-                                               {
-                                                       string val = (string) properties [attribute].Value;
-                                                       attr = new LdapAttribute( attribute , val);
-                                               }
-                                               else
-                                               {
-                                                       object[] vals =(object []) properties [attribute].Value;
-                                                       string[] aStrVals = new string [properties [attribute].Count];
-                                                       Array.Copy (vals,0,aStrVals,0,properties [attribute].Count);
-                                                       attr = new LdapAttribute( attribute , aStrVals);
+                                               switch (properties [attribute].Count) {
+                                                       case 0:
+                                                               attr = new LdapAttribute (attribute, new string [0]);
+                                                               modList.Add (new LdapModification (LdapModification.DELETE, attr));
+                                                               break;
+                                                       case 1:
+                                                               string val = (string) properties [attribute].Value;
+                                                               attr = new LdapAttribute (attribute, val);
+                                                               modList.Add (new LdapModification (LdapModification.REPLACE, attr));
+                                                               break;
+                                                       default:
+                                                               object [] vals = (object [])properties [attribute].Value;
+                                                               string [] aStrVals = new string [properties [attribute].Count];
+                                                               Array.Copy (vals, 0, aStrVals, 0, properties [attribute].Count);
+                                                               attr = new LdapAttribute (attribute, aStrVals);
+                                                               modList.Add (new LdapModification (LdapModification.REPLACE, attr));
+                                                               break;
                                                }
-                                               modList.Add( new LdapModification(LdapModification.REPLACE, attr));
                                                properties [attribute].Mbit=false;
                                        }
                                }
                                if (modList.Count > 0) {
                                        LdapModification[] mods = new LdapModification[modList.Count];  
-                                       Type mtype=Type.GetType("System.DirectoryServices.LdapModification");
-                                       mods = (LdapModification[])modList.ToArray(typeof(LdapModification));
+                                       Type mtype = typeof (LdapModification);
+                                       mods = (LdapModification[])modList.ToArray(mtype);
                                        ModEntry(mods);
                                }
                        }