// Decompiled with JetBrains decompiler // Type: Rei.Net.HttpServer.MyEndPoint // Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null // MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28 // Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll using System; using System.ComponentModel; using System.Diagnostics; using System.Net; using System.Net.Sockets; using System.Xml.Serialization; namespace Rei.Net.HttpServer { [DebuggerDisplay("{ToString()}")] public class MyEndPoint { [XmlIgnore] public IPEndPoint IPEndPoint; public MyEndPoint() : this(IPAddress.Loopback, 0) { } public MyEndPoint(IPAddress address, int port) { this.IPEndPoint = new IPEndPoint(address, port); } public MyEndPoint(string str) { this.IPEndPoint = MyEndPoint.Parse(str).IPEndPoint; } public MyEndPoint(IPEndPoint ep) { this.IPEndPoint = ep; } public override bool Equals(object obj) { return this.IPEndPoint.Equals((object) (obj as MyEndPoint).IPEndPoint); } public override int GetHashCode() { return this.IPEndPoint.GetHashCode(); } [Browsable(false)] [System.Xml.Serialization.XmlText] public string XmlText { get { return this.ToString(); } set { this.IPEndPoint = MyEndPoint.Parse(value).IPEndPoint; } } public bool IsLoopback { get { return IPAddress.IsLoopback(this.IPEndPoint.Address); } } public string Host { get { return this.IPEndPoint.Address.ToString(); } } public int Port { get { return this.IPEndPoint.Port; } } public override string ToString() { string str = this.IPEndPoint.Address.ToString(); if (this.IPEndPoint.Address.AddressFamily == AddressFamily.InterNetworkV6) str = "[" + str + "]"; if (this.IPEndPoint.Port < 0) return str; return str + ":" + this.IPEndPoint.Port.ToString(); } public static MyEndPoint Parse(string s) { MyEndPoint result = (MyEndPoint) null; if (MyEndPoint.TryParse(s, ref result)) return result; throw new ArgumentException(); } public static bool TryParse(string s, ref MyEndPoint result) { if (string.IsNullOrEmpty(s)) return false; s = s.Trim(); if (s.Length < 2) return false; int startIndex1; int startIndex2; int startIndex3; if ((int) s[0] == 91) { startIndex1 = 1; startIndex2 = s.LastIndexOf("]"); if (startIndex2 < 0) return false; int num = s.IndexOf(":", startIndex2); if (num < 0 || num >= checked (s.Length - 1)) return false; startIndex3 = checked (num + 1); } else { startIndex1 = 0; startIndex2 = s.IndexOf(":"); if (startIndex2 < 0 || startIndex2 >= checked (s.Length - 1)) return false; startIndex3 = checked (startIndex2 + 1); } IPAddress address = (IPAddress) null; int result1; if (!IPAddress.TryParse(s.Substring(startIndex1, checked (startIndex2 - startIndex1)), out address) || !int.TryParse(s.Substring(startIndex3, checked (s.Length - startIndex3)), out result1) || (result1 < 0 || result1 > (int) ushort.MaxValue)) return false; result = new MyEndPoint(address, result1); return true; } } }