Couple of fixes around XmlSyndicationContent.GetReaderAtContent().
[mono.git] / mcs / class / Mono.Posix / Mono.Posix / UnixEndPoint.cs
index 6d811c84da4adced3b263ba6cb505e1cc0cbd3fe..710a5ad5a1d68521199a304dd258db009bbef733 100644 (file)
@@ -35,12 +35,18 @@ using System.Text;
 namespace Mono.Posix
 {
        [Serializable]
+       [Obsolete ("Use Mono.Unix.UnixEndPoint")]
        public class UnixEndPoint : EndPoint
        {
                string filename;
                
                public UnixEndPoint (string filename)
                {
+                       if (filename == null)
+                               throw new ArgumentNullException ("filename");
+
+                       if (filename == "")
+                               throw new ArgumentException ("Cannot be empty.", "filename");
                        this.filename = filename;
                }
                
@@ -59,8 +65,6 @@ namespace Mono.Posix
 
                public override EndPoint Create (SocketAddress socketAddress)
                {
-                       int size = socketAddress.Size;
-                       byte [] bytes = new byte [size];
                        /*
                         * Should also check this
                         *
@@ -72,8 +76,9 @@ namespace Mono.Posix
                                throw new ArgumentException ("socketAddress is not a unix socket address.");
                         */
 
-                       for (int i = 2; i < size - 2; i++) {
-                               bytes [i] = socketAddress [i];
+                       byte [] bytes = new byte [socketAddress.Size - 2];
+                       for (int i = 0; i < bytes.Length; i++) {
+                               bytes [i] = socketAddress [i + 2];
                        }
 
                        string name = Encoding.Default.GetString (bytes);
@@ -94,6 +99,20 @@ namespace Mono.Posix
                public override string ToString() {
                        return(filename);
                }
+
+               public override int GetHashCode ()
+               {
+                       return filename.GetHashCode ();
+               }
+
+               public override bool Equals (object o)
+               {
+                       UnixEndPoint other = o as UnixEndPoint;
+                       if (other == null)
+                               return false;
+
+                       return (other.filename == filename);
+               }
        }
 }