Refactored Ext.cs
This commit is contained in:
		| @@ -1,8 +1,8 @@ | |||||||
| #region License | #region License | ||||||
| /* | /* | ||||||
|  * Ext.cs |  * Ext.cs | ||||||
|  *  IsPredefinedScheme and MaybeUri methods derived from System.Uri.cs |  *  IsPredefinedScheme and MaybeUri methods are derived from System.Uri.cs | ||||||
|  *  GetStatusDescription method derived from System.Net.HttpListenerResponse.cs |  *  GetStatusDescription method is derived from System.Net.HttpListenerResponse.cs | ||||||
|  * |  * | ||||||
|  * The MIT License |  * The MIT License | ||||||
|  * |  * | ||||||
| @@ -50,13 +50,13 @@ using System.Text; | |||||||
| using WebSocketSharp.Net; | using WebSocketSharp.Net; | ||||||
| using WebSocketSharp.Net.WebSockets; | using WebSocketSharp.Net.WebSockets; | ||||||
|  |  | ||||||
| namespace WebSocketSharp { | namespace WebSocketSharp | ||||||
|  | { | ||||||
|   /// <summary> |   /// <summary> | ||||||
|   /// Provides a set of static methods for the websocket-sharp. |   /// Provides a set of static methods for the websocket-sharp. | ||||||
|   /// </summary> |   /// </summary> | ||||||
|   public static class Ext { |   public static class Ext | ||||||
|  |   { | ||||||
|     #region Private Const Fields |     #region Private Const Fields | ||||||
|  |  | ||||||
|     private const string _tspecials = "()<>@,;:\\\"/[]?={} \t"; |     private const string _tspecials = "()<>@,;:\\\"/[]?={} \t"; | ||||||
| @@ -273,8 +273,7 @@ namespace WebSocketSharp { | |||||||
|         return "What we've got here is a failure to communicate in the WebSocket protocol."; |         return "What we've got here is a failure to communicate in the WebSocket protocol."; | ||||||
|  |  | ||||||
|       if (code == CloseStatusCode.TOO_BIG) |       if (code == CloseStatusCode.TOO_BIG) | ||||||
|         return String.Format( |         return String.Format ("The size of received payload data is bigger than the allowable value ({0} bytes).", | ||||||
|           "The size of received payload data is bigger than the allowable value ({0} bytes).", |  | ||||||
|           PayloadData.MaxLength); |           PayloadData.MaxLength); | ||||||
|  |  | ||||||
|       return String.Empty; |       return String.Empty; | ||||||
| @@ -299,52 +298,6 @@ namespace WebSocketSharp { | |||||||
|       return value.StartsWith ("permessage-"); |       return value.StartsWith ("permessage-"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // <summary> |  | ||||||
|     // Determines whether the specified object is <see langword="null"/>. |  | ||||||
|     // </summary> |  | ||||||
|     // <returns> |  | ||||||
|     // <c>true</c> if <paramref name="obj"/> is <see langword="null"/>; otherwise, <c>false</c>. |  | ||||||
|     // </returns> |  | ||||||
|     // <param name="obj"> |  | ||||||
|     // An <b>object</b> to test. |  | ||||||
|     // </param> |  | ||||||
|     // <typeparam name="T"> |  | ||||||
|     // The type of <paramref name="obj"/> parameter. |  | ||||||
|     // </typeparam> |  | ||||||
|     internal static bool IsNull<T>(this T obj) |  | ||||||
|       where T : class |  | ||||||
|     { |  | ||||||
|       return obj == null; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     // <summary> |  | ||||||
|     // Determines whether the specified object is <see langword="null"/>, |  | ||||||
|     // and invokes the specified <see cref="Action"/> delegate if the object is <see langword="null"/>. |  | ||||||
|     // </summary> |  | ||||||
|     // <returns> |  | ||||||
|     // <c>true</c> if <paramref name="obj"/> is <see langword="null"/>; otherwise, <c>false</c>. |  | ||||||
|     // </returns> |  | ||||||
|     // <param name="obj"> |  | ||||||
|     // A <b>class</b> to test. |  | ||||||
|     // </param> |  | ||||||
|     // <param name="action"> |  | ||||||
|     // An <see cref="Action"/> delegate that references the method(s) called if <paramref name="obj"/> is <see langword="null"/>. |  | ||||||
|     // </param> |  | ||||||
|     // <typeparam name="T"> |  | ||||||
|     // The type of <paramref name="obj"/>. |  | ||||||
|     // </typeparam> |  | ||||||
|     internal static bool IsNullDo<T>(this T obj, Action action) |  | ||||||
|       where T : class |  | ||||||
|     { |  | ||||||
|       if (obj == null) |  | ||||||
|       { |  | ||||||
|         action(); |  | ||||||
|         return true; |  | ||||||
|       } |  | ||||||
|  |  | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     internal static bool IsText (this string value) |     internal static bool IsText (this string value) | ||||||
|     { |     { | ||||||
|       int len = value.Length; |       int len = value.Length; | ||||||
| @@ -545,10 +498,7 @@ namespace WebSocketSharp { | |||||||
|       var start = value.IndexOf ('\"'); |       var start = value.IndexOf ('\"'); | ||||||
|       var end = value.LastIndexOf ('\"'); |       var end = value.LastIndexOf ('\"'); | ||||||
|       if (start < end) |       if (start < end) | ||||||
|       { |         value = value.Substring (start + 1, end - start - 1).Replace ("\\\"", "\""); | ||||||
|         value = value.Substring(start + 1, end - start - 1) |  | ||||||
|                 .Replace("\\\"", "\""); |  | ||||||
|       } |  | ||||||
|  |  | ||||||
|       return value.Trim (); |       return value.Trim (); | ||||||
|     } |     } | ||||||
| @@ -570,7 +520,8 @@ namespace WebSocketSharp { | |||||||
|     /// in the specified array of <see cref="char"/>. |     /// in the specified array of <see cref="char"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// <c>true</c> if <paramref name="value"/> contains any of <paramref name="chars"/>; otherwise, <c>false</c>. |     /// <c>true</c> if <paramref name="value"/> contains any of <paramref name="chars"/>; | ||||||
|  |     /// otherwise, <c>false</c>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="value"> |     /// <param name="value"> | ||||||
|     /// A <see cref="string"/> to test. |     /// A <see cref="string"/> to test. | ||||||
| @@ -596,7 +547,7 @@ namespace WebSocketSharp { | |||||||
|     /// otherwise, <c>false</c>. |     /// otherwise, <c>false</c>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="collection"> |     /// <param name="collection"> | ||||||
|     /// A <see cref="NameValueCollection"/> that contains the entries. |     /// A <see cref="NameValueCollection"/> to test. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="name"> |     /// <param name="name"> | ||||||
|     /// A <see cref="string"/> that contains the key of the entry to find. |     /// A <see cref="string"/> that contains the key of the entry to find. | ||||||
| @@ -613,11 +564,11 @@ namespace WebSocketSharp { | |||||||
|     /// with the specified both <paramref name="name"/> and <paramref name="value"/>. |     /// with the specified both <paramref name="name"/> and <paramref name="value"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// <c>true</c> if <paramref name="collection"/> contains the entry with both <paramref name="name"/> and <paramref name="value"/>; |     /// <c>true</c> if <paramref name="collection"/> contains the entry with both <paramref name="name"/> | ||||||
|     /// otherwise, <c>false</c>. |     /// and <paramref name="value"/>; otherwise, <c>false</c>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="collection"> |     /// <param name="collection"> | ||||||
|     /// A <see cref="NameValueCollection"/> that contains the entries. |     /// A <see cref="NameValueCollection"/> to test. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="name"> |     /// <param name="name"> | ||||||
|     /// A <see cref="string"/> that contains the key of the entry to find. |     /// A <see cref="string"/> that contains the key of the entry to find. | ||||||
| @@ -642,16 +593,16 @@ namespace WebSocketSharp { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Emit the specified <see cref="EventHandler"/> delegate if is not <see langword="null"/>. |     /// Emits the specified <see cref="EventHandler"/> delegate if not <see langword="null"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <param name="eventHandler"> |     /// <param name="eventHandler"> | ||||||
|     /// An <see cref="EventHandler"/> to emit. |     /// A <see cref="EventHandler"/> to emit. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="sender"> |     /// <param name="sender"> | ||||||
|     /// An <see cref="object"/> that emits the <paramref name="eventHandler"/>. |     /// An <see cref="object"/> from which emits this <paramref name="eventHandler"/>. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="e"> |     /// <param name="e"> | ||||||
|     /// An <see cref="EventArgs"/> that contains no event data. |     /// A <see cref="EventArgs"/> that contains no event data. | ||||||
|     /// </param> |     /// </param> | ||||||
|     public static void Emit ( |     public static void Emit ( | ||||||
|       this EventHandler eventHandler, object sender, EventArgs e) |       this EventHandler eventHandler, object sender, EventArgs e) | ||||||
| @@ -661,13 +612,13 @@ namespace WebSocketSharp { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Emit the specified <b>EventHandler<TEventArgs></b> delegate if is not <see langword="null"/>. |     /// Emits the specified <b>EventHandler<TEventArgs></b> delegate if not <see langword="null"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <param name="eventHandler"> |     /// <param name="eventHandler"> | ||||||
|     /// An <b>EventHandler<TEventArgs></b> to emit. |     /// An <b>EventHandler<TEventArgs></b> to emit. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="sender"> |     /// <param name="sender"> | ||||||
|     /// An <see cref="object"/> that emits the <paramref name="eventHandler"/>. |     /// An <see cref="object"/> from which emits this <paramref name="eventHandler"/>. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="e"> |     /// <param name="e"> | ||||||
|     /// A <b>TEventArgs</b> that contains the event data. |     /// A <b>TEventArgs</b> that contains the event data. | ||||||
| @@ -687,10 +638,11 @@ namespace WebSocketSharp { | |||||||
|     /// Gets the absolute path from the specified <see cref="Uri"/>. |     /// Gets the absolute path from the specified <see cref="Uri"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// A <see cref="string"/> that contains the absolute path if got successfully; otherwise, <see langword="null"/>. |     /// A <see cref="string"/> that contains the absolute path if gets successfully; | ||||||
|  |     /// otherwise, <see langword="null"/>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="uri"> |     /// <param name="uri"> | ||||||
|     /// A <see cref="Uri"/> that contains the URI to get the absolute path from. |     /// A <see cref="Uri"/> that contains a URI to get the absolute path from. | ||||||
|     /// </param> |     /// </param> | ||||||
|     public static string GetAbsolutePath (this Uri uri) |     public static string GetAbsolutePath (this Uri uri) | ||||||
|     { |     { | ||||||
| @@ -733,13 +685,13 @@ namespace WebSocketSharp { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Gets the description of the HTTP status code using the specified <see cref="WebSocketSharp.Net.HttpStatusCode"/>. |     /// Gets the description of the HTTP status code using the specified <see cref="HttpStatusCode"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// A <see cref="string"/> that contains the description of the HTTP status code. |     /// A <see cref="string"/> that contains the description of an HTTP status code. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="code"> |     /// <param name="code"> | ||||||
|     /// One of <see cref="WebSocketSharp.Net.HttpStatusCode"/> values that contains an HTTP status code. |     /// One of <see cref="HttpStatusCode"/> values that indicates an HTTP status code. | ||||||
|     /// </param> |     /// </param> | ||||||
|     public static string GetDescription (this HttpStatusCode code) |     public static string GetDescription (this HttpStatusCode code) | ||||||
|     { |     { | ||||||
| @@ -768,13 +720,14 @@ namespace WebSocketSharp { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Gets the name and value from the specified <see cref="string"/> that contains a pair of name and value are separated by a separator string. |     /// Gets the name and value from the specified <see cref="string"/> that contains a pair of name and value | ||||||
|  |     /// separated by a separator string. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// A <b>KeyValuePair<string, string></b> that contains the name and value if any. |     /// A <b>KeyValuePair<string, string></b> that contains the name and value if any. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="nameAndValue"> |     /// <param name="nameAndValue"> | ||||||
|     /// A <see cref="string"/> that contains a pair of name and value are separated by a separator string. |     /// A <see cref="string"/> that contains a pair of name and value separated by a separator string. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="separator"> |     /// <param name="separator"> | ||||||
|     /// A <see cref="string"/> that contains a separator string. |     /// A <see cref="string"/> that contains a separator string. | ||||||
| @@ -792,7 +745,7 @@ namespace WebSocketSharp { | |||||||
|     /// Gets the description of the HTTP status code using the specified <see cref="int"/>. |     /// Gets the description of the HTTP status code using the specified <see cref="int"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// A <see cref="string"/> that contains the description of the HTTP status code. |     /// A <see cref="string"/> that contains the description of an HTTP status code. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="code"> |     /// <param name="code"> | ||||||
|     /// An <see cref="int"/> that contains an HTTP status code. |     /// An <see cref="int"/> that contains an HTTP status code. | ||||||
| @@ -907,20 +860,6 @@ namespace WebSocketSharp { | |||||||
|                : true; |                : true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |  | ||||||
|     /// Determines whether the specified <see cref="string"/> is empty. |  | ||||||
|     /// </summary> |  | ||||||
|     /// <returns> |  | ||||||
|     /// <c>true</c> if <paramref name="value"/> is empty; otherwise, <c>false</c>. |  | ||||||
|     /// </returns> |  | ||||||
|     /// <param name="value"> |  | ||||||
|     /// A <see cref="string"/> to test. |  | ||||||
|     /// </param> |  | ||||||
|     public static bool IsEmpty(this string value) |  | ||||||
|     { |  | ||||||
|       return value.Length == 0; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Determines whether the specified <see cref="string"/> is enclosed in the specified <see cref="char"/>. |     /// Determines whether the specified <see cref="string"/> is enclosed in the specified <see cref="char"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
| @@ -941,13 +880,13 @@ namespace WebSocketSharp { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Determines whether the specified <see cref="WebSocketSharp.ByteOrder"/> is host (this computer architecture) byte order. |     /// Determines whether the specified <see cref="ByteOrder"/> is host (this computer architecture) byte order. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// <c>true</c> if the <paramref name="order"/> parameter is host byte order; otherwise, <c>false</c>. |     /// <c>true</c> if <paramref name="order"/> is host byte order; otherwise, <c>false</c>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="order"> |     /// <param name="order"> | ||||||
|     /// A <see cref="WebSocketSharp.ByteOrder"/> to test. |     /// A <see cref="ByteOrder"/> to test. | ||||||
|     /// </param> |     /// </param> | ||||||
|     public static bool IsHostOrder (this ByteOrder order) |     public static bool IsHostOrder (this ByteOrder order) | ||||||
|     { |     { | ||||||
| @@ -989,7 +928,7 @@ namespace WebSocketSharp { | |||||||
|     /// Determines whether the specified <see cref="string"/> is <see langword="null"/> or empty. |     /// Determines whether the specified <see cref="string"/> is <see langword="null"/> or empty. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// <c>true</c> if the <paramref name="value"/> parameter is <see langword="null"/> or empty; otherwise, <c>false</c>. |     /// <c>true</c> if <paramref name="value"/> is <see langword="null"/> or empty; otherwise, <c>false</c>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="value"> |     /// <param name="value"> | ||||||
|     /// A <see cref="string"/> to test. |     /// A <see cref="string"/> to test. | ||||||
| @@ -1000,10 +939,10 @@ namespace WebSocketSharp { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Determines whether the specified <see cref="string"/> is predefined scheme. |     /// Determines whether the specified <see cref="string"/> is a predefined scheme. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// <c>true</c> if the <paramref name="scheme"/> parameter is the predefined scheme; otherwise, <c>false</c>. |     /// <c>true</c> if <paramref name="scheme"/> is a predefined scheme; otherwise, <c>false</c>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="scheme"> |     /// <param name="scheme"> | ||||||
|     /// A <see cref="string"/> to test. |     /// A <see cref="string"/> to test. | ||||||
| @@ -1015,39 +954,32 @@ namespace WebSocketSharp { | |||||||
|  |  | ||||||
|       char c = scheme [0]; |       char c = scheme [0]; | ||||||
|       if (c == 'h') |       if (c == 'h') | ||||||
|         return (scheme == "http" || scheme == "https"); |         return scheme == "http" || scheme == "https"; | ||||||
|  |  | ||||||
|       if (c == 'f') |       if (c == 'f') | ||||||
|         return (scheme == "file" || scheme == "ftp"); |         return scheme == "file" || scheme == "ftp"; | ||||||
|  |  | ||||||
|       if (c == 'w') |       if (c == 'w') | ||||||
|         return (scheme == "ws" || scheme == "wss"); |         return scheme == "ws" || scheme == "wss"; | ||||||
|  |  | ||||||
|       if (c == 'n') |       if (c == 'n') | ||||||
|       { |       { | ||||||
|         c = scheme [1]; |         c = scheme [1]; | ||||||
|         if (c == 'e') |         return c == 'e' | ||||||
|           return (scheme == "news" || scheme == "net.pipe" || scheme == "net.tcp"); |                ? scheme == "news" || scheme == "net.pipe" || scheme == "net.tcp" | ||||||
|  |                : scheme == "nntp"; | ||||||
|         if (scheme == "nntp") |  | ||||||
|           return true; |  | ||||||
|  |  | ||||||
|         return false; |  | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       if ((c == 'g' && scheme == "gopher") || (c == 'm' && scheme == "mailto")) |       return (c == 'g' && scheme == "gopher") || (c == 'm' && scheme == "mailto"); | ||||||
|         return true; |  | ||||||
|  |  | ||||||
|       return false; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Determines whether the specified <see cref="HttpListenerRequest"/> is the HTTP Upgrade request |     /// Determines whether the specified <see cref="HttpListenerRequest"/> is an HTTP Upgrade request | ||||||
|     /// to switch to the specified <paramref name="protocol"/>. |     /// to switch to the specified <paramref name="protocol"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// <c>true</c> if the specified <see cref="HttpListenerRequest"/> is the HTTP Upgrade request |     /// <c>true</c> if <paramref name="request"/> is an HTTP Upgrade request | ||||||
|     /// to switch to the specified <paramref name="protocol"/>; otherwise, <c>false</c>. |     /// to switch to <paramref name="protocol"/>; otherwise, <c>false</c>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="request"> |     /// <param name="request"> | ||||||
|     /// A <see cref="HttpListenerRequest"/> that contains an HTTP request information. |     /// A <see cref="HttpListenerRequest"/> that contains an HTTP request information. | ||||||
| @@ -1080,26 +1012,21 @@ namespace WebSocketSharp { | |||||||
|       if (protocol.Length == 0) |       if (protocol.Length == 0) | ||||||
|         throw new ArgumentException ("Must not be empty.", "protocol"); |         throw new ArgumentException ("Must not be empty.", "protocol"); | ||||||
|  |  | ||||||
|       if (!request.Headers.Contains("Upgrade", protocol)) |       return request.Headers.Contains ("Upgrade", protocol) && | ||||||
|         return false; |              request.Headers.Contains ("Connection", "Upgrade"); | ||||||
|  |  | ||||||
|       if (!request.Headers.Contains("Connection", "Upgrade")) |  | ||||||
|         return false; |  | ||||||
|  |  | ||||||
|       return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Determines whether the specified <see cref="string"/> is valid absolute path. |     /// Determines whether the specified <see cref="string"/> is valid absolute path. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// <c>true</c> if the <paramref name="absPath"/> parameter is valid absolute path; otherwise, <c>false</c>. |     /// <c>true</c> if <paramref name="absPath"/> is valid absolute path; otherwise, <c>false</c>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="absPath"> |     /// <param name="absPath"> | ||||||
|     /// A <see cref="string"/> to test. |     /// A <see cref="string"/> to test. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="message"> |     /// <param name="message"> | ||||||
|     /// A <see cref="string"/> that receives a message if the <paramref name="absPath"/> is invalid. |     /// A <see cref="string"/> that receives a message if <paramref name="absPath"/> is invalid. | ||||||
|     /// </param> |     /// </param> | ||||||
|     public static bool IsValidAbsolutePath (this string absPath, out string message) |     public static bool IsValidAbsolutePath (this string absPath, out string message) | ||||||
|     { |     { | ||||||
| @@ -1131,7 +1058,7 @@ namespace WebSocketSharp { | |||||||
|     /// Determines whether the specified <see cref="string"/> is a URI string. |     /// Determines whether the specified <see cref="string"/> is a URI string. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// <c>true</c> if the <paramref name="uriString"/> parameter is maybe a URI string; otherwise, <c>false</c>. |     /// <c>true</c> if <paramref name="uriString"/> is maybe a URI string; otherwise, <c>false</c>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="uriString"> |     /// <param name="uriString"> | ||||||
|     /// A <see cref="string"/> to test. |     /// A <see cref="string"/> to test. | ||||||
| @@ -1194,7 +1121,8 @@ namespace WebSocketSharp { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Retrieves a sub-array from the specified <paramref name="array"/>. A sub-array starts at the specified element position. |     /// Retrieves a sub-array from the specified <paramref name="array"/>. | ||||||
|  |     /// A sub-array starts at the specified element position. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// An array of T that receives a sub-array, or an empty array of T if any problems with the parameters. |     /// An array of T that receives a sub-array, or an empty array of T if any problems with the parameters. | ||||||
| @@ -1203,7 +1131,7 @@ namespace WebSocketSharp { | |||||||
|     /// An array of T that contains the data to retrieve a sub-array. |     /// An array of T that contains the data to retrieve a sub-array. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="startIndex"> |     /// <param name="startIndex"> | ||||||
|     /// An <see cref="int"/> that contains the zero-based starting position of a sub-array in the <paramref name="array"/>. |     /// An <see cref="int"/> that contains the zero-based starting position of a sub-array in <paramref name="array"/>. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="length"> |     /// <param name="length"> | ||||||
|     /// An <see cref="int"/> that contains the number of elements to retrieve a sub-array. |     /// An <see cref="int"/> that contains the number of elements to retrieve a sub-array. | ||||||
| @@ -1373,7 +1301,7 @@ namespace WebSocketSharp { | |||||||
|     /// An array of <see cref="byte"/> to convert. |     /// An array of <see cref="byte"/> to convert. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="srcOrder"> |     /// <param name="srcOrder"> | ||||||
|     /// A <see cref="WebSocketSharp.ByteOrder"/> that indicates the byte order of <paramref name="src"/>. |     /// A <see cref="ByteOrder"/> that indicates the byte order of <paramref name="src"/>. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <typeparam name="T"> |     /// <typeparam name="T"> | ||||||
|     /// The type of the return. The T must be a value type. |     /// The type of the return. The T must be a value type. | ||||||
| @@ -1426,7 +1354,7 @@ namespace WebSocketSharp { | |||||||
|     /// A T to convert. |     /// A T to convert. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="order"> |     /// <param name="order"> | ||||||
|     /// A <see cref="WebSocketSharp.ByteOrder"/> that indicates the byte order of the return. |     /// A <see cref="ByteOrder"/> that indicates the byte order of the return. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <typeparam name="T"> |     /// <typeparam name="T"> | ||||||
|     /// The type of <paramref name="value"/>. The T must be a value type. |     /// The type of <paramref name="value"/>. The T must be a value type. | ||||||
| @@ -1495,7 +1423,7 @@ namespace WebSocketSharp { | |||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// A <see cref="string"/> converted from <paramref name="array"/>, or a <see cref="String.Empty"/> |     /// A <see cref="string"/> converted from <paramref name="array"/>, or a <see cref="String.Empty"/> | ||||||
|     /// if the length of <paramref name="array"/> is zero. |     /// if <paramref name="array"/> is empty. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="array"> |     /// <param name="array"> | ||||||
|     /// An array of T to convert. |     /// An array of T to convert. | ||||||
| @@ -1531,11 +1459,11 @@ namespace WebSocketSharp { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Converts the specified <see cref="string"/> to a <see cref="Uri"/> object. |     /// Converts the specified <see cref="string"/> to a <see cref="Uri"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// A <see cref="Uri"/> converted from the <paramref name="uriString"/> parameter, or <see langword="null"/> |     /// A <see cref="Uri"/> converted from <paramref name="uriString"/>, or <see langword="null"/> | ||||||
|     /// if the <paramref name="uriString"/> is <see langword="null"/> or <see cref="String.Empty"/>. |     /// if <paramref name="uriString"/> is <see langword="null"/> or <see cref="String.Empty"/>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="uriString"> |     /// <param name="uriString"> | ||||||
|     /// A <see cref="string"/> to convert. |     /// A <see cref="string"/> to convert. | ||||||
| @@ -1550,22 +1478,24 @@ namespace WebSocketSharp { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Tries to create a new WebSocket <see cref="Uri"/> using the specified <paramref name="uriString"/>. |     /// Tries to create a new WebSocket <see cref="Uri"/> with the specified <paramref name="uriString"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// <c>true</c> if the WebSocket <see cref="Uri"/> was successfully created; otherwise, <c>false</c>. |     /// <c>true</c> if a WebSocket <see cref="Uri"/> is successfully created; otherwise, <c>false</c>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="uriString"> |     /// <param name="uriString"> | ||||||
|     /// A <see cref="string"/> that contains a WebSocket URI. |     /// A <see cref="string"/> that contains a WebSocket URI. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="result"> |     /// <param name="result"> | ||||||
|     /// When this method returns, contains a created WebSocket <see cref="Uri"/> if the <paramref name="uriString"/> parameter is valid WebSocket URI; otherwise, <see langword="null"/>. |     /// When this method returns, contains a created WebSocket <see cref="Uri"/> | ||||||
|  |     /// if <paramref name="uriString"/> is valid WebSocket URI; otherwise, <see langword="null"/>. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="message"> |     /// <param name="message"> | ||||||
|     /// When this method returns, contains a error message <see cref="string"/> if the <paramref name="uriString"/> parameter is invalid WebSocket URI; otherwise, <c>String.Empty</c>. |     /// When this method returns, contains a error message <see cref="string"/> | ||||||
|  |     /// if <paramref name="uriString"/> is invalid WebSocket URI; otherwise, <c>String.Empty</c>. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <exception cref="ArgumentNullException"> |     /// <exception cref="ArgumentNullException"> | ||||||
|     /// Is thrown when the <paramref name="uriString"/> parameter passed to a method is invalid because it is <see langword="null"/>. |     /// <paramref name="uriString"/> is <see langword="null"/>. | ||||||
|     /// </exception> |     /// </exception> | ||||||
|     public static bool TryCreateWebSocketUri (this string uriString, out Uri result, out string message) |     public static bool TryCreateWebSocketUri (this string uriString, out Uri result, out string message) | ||||||
|     { |     { | ||||||
| @@ -1606,16 +1536,13 @@ namespace WebSocketSharp { | |||||||
|         if ((scheme == "ws"  && port == 443) || |         if ((scheme == "ws"  && port == 443) || | ||||||
|             (scheme == "wss" && port == 80)) |             (scheme == "wss" && port == 80)) | ||||||
|         { |         { | ||||||
|           message = String.Format( |           message = String.Format ("Invalid pair of scheme and port: {0}, {1}", scheme, port); | ||||||
|             "Invalid pair of scheme and port: {0}, {1}", scheme, port); |  | ||||||
|           return false; |           return false; | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|       else |       else | ||||||
|       { |       { | ||||||
|         port = scheme == "ws" |         port = scheme == "ws" ? 80 : 443; | ||||||
|              ? 80 |  | ||||||
|              : 443; |  | ||||||
|         var url = String.Format ("{0}://{1}:{2}{3}", scheme, uri.Host, port, uri.PathAndQuery); |         var url = String.Format ("{0}://{1}:{2}{3}", scheme, uri.Host, port, uri.PathAndQuery); | ||||||
|         uri = url.ToUri (); |         uri = url.ToUri (); | ||||||
|       } |       } | ||||||
| @@ -1630,8 +1557,8 @@ namespace WebSocketSharp { | |||||||
|     /// URL-decodes the specified <see cref="string"/>. |     /// URL-decodes the specified <see cref="string"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// A <see cref="string"/> that receives a decoded string, or the <paramref name="s"/> parameter |     /// A <see cref="string"/> that receives a decoded string, or the <paramref name="s"/> | ||||||
|     /// if the <paramref name="s"/> is <see langword="null"/> or <see cref="String.Empty"/>. |     /// if <paramref name="s"/> is <see langword="null"/> or <see cref="String.Empty"/>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="s"> |     /// <param name="s"> | ||||||
|     /// A <see cref="string"/> to decode. |     /// A <see cref="string"/> to decode. | ||||||
| @@ -1647,8 +1574,8 @@ namespace WebSocketSharp { | |||||||
|     /// URL-encodes the specified <see cref="string"/>. |     /// URL-encodes the specified <see cref="string"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// A <see cref="string"/> that receives a encoded string, or the <paramref name="s"/> parameter |     /// A <see cref="string"/> that receives a encoded string, or the <paramref name="s"/> | ||||||
|     /// if the <paramref name="s"/> is <see langword="null"/> or <see cref="String.Empty"/>. |     /// if <paramref name="s"/> is <see langword="null"/> or <see cref="String.Empty"/>. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     /// <param name="s"> |     /// <param name="s"> | ||||||
|     /// A <see cref="string"/> to encode. |     /// A <see cref="string"/> to encode. | ||||||
| @@ -1661,16 +1588,16 @@ namespace WebSocketSharp { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Writes the specified content data using the specified <see cref="WebSocketSharp.Net.HttpListenerResponse"/>. |     /// Writes the specified content data using the specified <see cref="HttpListenerResponse"/>. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <param name="response"> |     /// <param name="response"> | ||||||
|     /// A <see cref="WebSocketSharp.Net.HttpListenerResponse"/> that contains a network stream to write a content data. |     /// A <see cref="HttpListenerResponse"/> that contains a network stream to write a content data. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <param name="content"> |     /// <param name="content"> | ||||||
|     /// An array of <see cref="byte"/> that contains a content data to write. |     /// An array of <see cref="byte"/> that contains a content data to write. | ||||||
|     /// </param> |     /// </param> | ||||||
|     /// <exception cref="ArgumentNullException"> |     /// <exception cref="ArgumentNullException"> | ||||||
|     /// Is thrown when the <paramref name="response"/> parameter passed to a method is invalid because it is <see langword="null"/>. |     /// <paramref name="response"/> is <see langword="null"/>. | ||||||
|     /// </exception> |     /// </exception> | ||||||
|     public static void WriteContent (this HttpListenerResponse response, byte [] content) |     public static void WriteContent (this HttpListenerResponse response, byte [] content) | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -37,8 +37,8 @@ using System.Text; | |||||||
| using System.Globalization; | using System.Globalization; | ||||||
| using System.Collections; | using System.Collections; | ||||||
|  |  | ||||||
| namespace WebSocketSharp.Net { | namespace WebSocketSharp.Net | ||||||
|  | { | ||||||
| 	/// <summary> | 	/// <summary> | ||||||
| 	/// Provides a set of properties and methods used to manage an HTTP Cookie. | 	/// Provides a set of properties and methods used to manage an HTTP Cookie. | ||||||
| 	/// </summary> | 	/// </summary> | ||||||
| @@ -54,8 +54,8 @@ namespace WebSocketSharp.Net { | |||||||
| 	///   </para> | 	///   </para> | ||||||
| 	/// </remarks> | 	/// </remarks> | ||||||
| 	[Serializable] | 	[Serializable] | ||||||
| 	public sealed class Cookie { | 	public sealed class Cookie | ||||||
|  | 	{ | ||||||
| 		#region Static Private Fields | 		#region Static Private Fields | ||||||
|  |  | ||||||
| 		static char [] reservedCharsForName = new char [] {' ', '=', ';', ',', '\n', '\r', '\t'}; | 		static char [] reservedCharsForName = new char [] {' ', '=', ';', ',', '\n', '\r', '\t'}; | ||||||
| @@ -270,7 +270,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		/// </value> | 		/// </value> | ||||||
| 		public string Comment { | 		public string Comment { | ||||||
| 			get { return comment; } | 			get { return comment; } | ||||||
| 			set { comment = value.IsNull () ? String.Empty : value; } | 			set { comment = value ?? String.Empty; } | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| @@ -395,7 +395,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		/// </value> | 		/// </value> | ||||||
| 		public string Path { | 		public string Path { | ||||||
| 			get { return path; } | 			get { return path; } | ||||||
| 			set { path = value.IsNull () ? String.Empty : value; } | 			set { path = value ?? String.Empty; } | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| @@ -480,9 +480,7 @@ namespace WebSocketSharp.Net { | |||||||
| 				if (!CanSetValue (value, out msg)) | 				if (!CanSetValue (value, out msg)) | ||||||
| 					throw new CookieException (msg); | 					throw new CookieException (msg); | ||||||
|  |  | ||||||
| 				val = value.IsEmpty () | 				val = value.Length == 0 ? "\"\"" : value; | ||||||
| 				    ? "\"\"" |  | ||||||
| 				    : value; |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -528,7 +526,7 @@ namespace WebSocketSharp.Net { | |||||||
|  |  | ||||||
| 		static bool CanSetValue (string value, out string message) | 		static bool CanSetValue (string value, out string message) | ||||||
| 		{ | 		{ | ||||||
| 			if (value.IsNull ()) { | 			if (value == null) { | ||||||
| 				message = "Value must not be null."; | 				message = "Value must not be null."; | ||||||
| 				return false; | 				return false; | ||||||
| 			} | 			} | ||||||
| @@ -595,7 +593,7 @@ namespace WebSocketSharp.Net { | |||||||
| 			if (!comment.IsNullOrEmpty ()) | 			if (!comment.IsNullOrEmpty ()) | ||||||
| 				result.AppendFormat ("; Comment={0}", comment.UrlEncode ()); | 				result.AppendFormat ("; Comment={0}", comment.UrlEncode ()); | ||||||
|  |  | ||||||
| 			if (!commentUri.IsNull ()) | 			if (commentUri != null) | ||||||
| 				result.AppendFormat ("; CommentURL={0}", commentUri.OriginalString.Quote ()); | 				result.AppendFormat ("; CommentURL={0}", commentUri.OriginalString.Quote ()); | ||||||
|  |  | ||||||
| 			if (discard) | 			if (discard) | ||||||
| @@ -614,7 +612,7 @@ namespace WebSocketSharp.Net { | |||||||
| 			for (int i = 0; i < values.Length; i++) { | 			for (int i = 0; i < values.Length; i++) { | ||||||
| 				tmp [i] = int.MinValue; | 				tmp [i] = int.MinValue; | ||||||
| 				var v = values [i].Trim (); | 				var v = values [i].Trim (); | ||||||
| 				if (v.IsEmpty ()) | 				if (v.Length == 0) | ||||||
| 					continue; | 					continue; | ||||||
|  |  | ||||||
| 				if (!int.TryParse (v, out tmp [i])) { | 				if (!int.TryParse (v, out tmp [i])) { | ||||||
| @@ -636,7 +634,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		// From client to server | 		// From client to server | ||||||
| 		internal string ToRequestString (Uri uri) | 		internal string ToRequestString (Uri uri) | ||||||
| 		{ | 		{ | ||||||
| 			if (name.IsEmpty ()) | 			if (name.Length == 0) | ||||||
| 				return String.Empty; | 				return String.Empty; | ||||||
|  |  | ||||||
| 			if (version == 0) | 			if (version == 0) | ||||||
| @@ -646,12 +644,12 @@ namespace WebSocketSharp.Net { | |||||||
| 			result.AppendFormat ("$Version={0}; {1}={2}", version, name, val); | 			result.AppendFormat ("$Version={0}; {1}={2}", version, name, val); | ||||||
| 			if (!path.IsNullOrEmpty ()) | 			if (!path.IsNullOrEmpty ()) | ||||||
| 				result.AppendFormat ("; $Path={0}", path); | 				result.AppendFormat ("; $Path={0}", path); | ||||||
| 			else if (!uri.IsNull ()) | 			else if (uri != null) | ||||||
| 				result.AppendFormat ("; $Path={0}", uri.GetAbsolutePath ()); | 				result.AppendFormat ("; $Path={0}", uri.GetAbsolutePath ()); | ||||||
| 			else | 			else | ||||||
| 				result.Append ("; $Path=/"); | 				result.Append ("; $Path=/"); | ||||||
|  |  | ||||||
| 			bool append_domain = uri.IsNull () || uri.Host != domain; | 			bool append_domain = uri == null || uri.Host != domain; | ||||||
| 			if (append_domain && !domain.IsNullOrEmpty ()) | 			if (append_domain && !domain.IsNullOrEmpty ()) | ||||||
| 				result.AppendFormat ("; $Domain={0}", domain); | 				result.AppendFormat ("; $Domain={0}", domain); | ||||||
|  |  | ||||||
| @@ -667,7 +665,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		// From server to client | 		// From server to client | ||||||
| 		internal string ToResponseString () | 		internal string ToResponseString () | ||||||
| 		{ | 		{ | ||||||
| 			return name.IsEmpty () | 			return name.Length == 0 | ||||||
| 			       ? String.Empty | 			       ? String.Empty | ||||||
| 			       : version == 0 | 			       : version == 0 | ||||||
| 			         ? ToResponseStringVersion0 () | 			         ? ToResponseStringVersion0 () | ||||||
| @@ -691,7 +689,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		public override bool Equals (Object comparand) | 		public override bool Equals (Object comparand) | ||||||
| 		{ | 		{ | ||||||
| 			var cookie = comparand as Cookie; | 			var cookie = comparand as Cookie; | ||||||
| 			return !cookie.IsNull() && | 			return cookie != null && | ||||||
| 			       name.Equals (cookie.Name, StringComparison.InvariantCultureIgnoreCase) && | 			       name.Equals (cookie.Name, StringComparison.InvariantCultureIgnoreCase) && | ||||||
| 			       val.Equals (cookie.Value, StringComparison.InvariantCulture) && | 			       val.Equals (cookie.Value, StringComparison.InvariantCulture) && | ||||||
| 			       path.Equals (cookie.Path, StringComparison.InvariantCulture) && | 			       path.Equals (cookie.Path, StringComparison.InvariantCulture) && | ||||||
|   | |||||||
| @@ -179,7 +179,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		/// </exception> | 		/// </exception> | ||||||
| 		public Cookie this [string name] { | 		public Cookie this [string name] { | ||||||
| 			get { | 			get { | ||||||
| 				if (name.IsNull ()) | 				if (name == null) | ||||||
| 					throw new ArgumentNullException ("name"); | 					throw new ArgumentNullException ("name"); | ||||||
|  |  | ||||||
| 				foreach (var cookie in Sorted) { | 				foreach (var cookie in Sorted) { | ||||||
| @@ -199,7 +199,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		/// </value> | 		/// </value> | ||||||
| 		public Object SyncRoot { | 		public Object SyncRoot { | ||||||
| 			get { | 			get { | ||||||
| 				if (sync.IsNull ()) | 				if (sync == null) | ||||||
| 					sync = new object (); | 					sync = new object (); | ||||||
|  |  | ||||||
| 				return sync; | 				return sync; | ||||||
| @@ -219,18 +219,18 @@ namespace WebSocketSharp.Net { | |||||||
| 			string [] pairs = Split(value).ToArray(); | 			string [] pairs = Split(value).ToArray(); | ||||||
| 			for (int i = 0; i < pairs.Length; i++) { | 			for (int i = 0; i < pairs.Length; i++) { | ||||||
| 				string pair = pairs [i].Trim (); | 				string pair = pairs [i].Trim (); | ||||||
| 				if (pair.IsEmpty ()) | 				if (pair.Length == 0) | ||||||
| 					continue; | 					continue; | ||||||
|  |  | ||||||
| 				if (pair.StartsWith ("$version", StringComparison.InvariantCultureIgnoreCase)) { | 				if (pair.StartsWith ("$version", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| 					version = Int32.Parse (pair.GetValueInternal ("=").Trim ('"')); | 					version = Int32.Parse (pair.GetValueInternal ("=").Trim ('"')); | ||||||
| 				} | 				} | ||||||
| 				else if (pair.StartsWith ("$path", StringComparison.InvariantCultureIgnoreCase)) { | 				else if (pair.StartsWith ("$path", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookie.Path = pair.GetValueInternal ("="); | 						cookie.Path = pair.GetValueInternal ("="); | ||||||
| 				} | 				} | ||||||
| 				else if (pair.StartsWith ("$domain", StringComparison.InvariantCultureIgnoreCase)) { | 				else if (pair.StartsWith ("$domain", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookie.Domain = pair.GetValueInternal ("="); | 						cookie.Domain = pair.GetValueInternal ("="); | ||||||
| 				} | 				} | ||||||
| 				else if (pair.StartsWith ("$port", StringComparison.InvariantCultureIgnoreCase)) { | 				else if (pair.StartsWith ("$port", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| @@ -238,11 +238,11 @@ namespace WebSocketSharp.Net { | |||||||
| 					         ? "\"\"" | 					         ? "\"\"" | ||||||
| 					         : pair.GetValueInternal ("="); | 					         : pair.GetValueInternal ("="); | ||||||
|  |  | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookie.Port = port; | 						cookie.Port = port; | ||||||
| 				} | 				} | ||||||
| 				else { | 				else { | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookies.Add (cookie); | 						cookies.Add (cookie); | ||||||
|  |  | ||||||
| 					string name; | 					string name; | ||||||
| @@ -265,7 +265,7 @@ namespace WebSocketSharp.Net { | |||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			if (!cookie.IsNull ()) | 			if (cookie != null) | ||||||
| 				cookies.Add (cookie); | 				cookies.Add (cookie); | ||||||
|  |  | ||||||
| 			return cookies; | 			return cookies; | ||||||
| @@ -279,11 +279,11 @@ namespace WebSocketSharp.Net { | |||||||
| 			string [] pairs = Split(value).ToArray(); | 			string [] pairs = Split(value).ToArray(); | ||||||
| 			for (int i = 0; i < pairs.Length; i++) { | 			for (int i = 0; i < pairs.Length; i++) { | ||||||
| 				string pair = pairs [i].Trim (); | 				string pair = pairs [i].Trim (); | ||||||
| 				if (pair.IsEmpty ()) | 				if (pair.Length == 0) | ||||||
| 					continue; | 					continue; | ||||||
|  |  | ||||||
| 				if (pair.StartsWith ("version", StringComparison.InvariantCultureIgnoreCase)) { | 				if (pair.StartsWith ("version", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookie.Version = Int32.Parse (pair.GetValueInternal ("=").Trim ('"')); | 						cookie.Version = Int32.Parse (pair.GetValueInternal ("=").Trim ('"')); | ||||||
| 				} | 				} | ||||||
| 				else if (pair.StartsWith ("expires", StringComparison.InvariantCultureIgnoreCase)) { | 				else if (pair.StartsWith ("expires", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| @@ -299,21 +299,21 @@ namespace WebSocketSharp.Net { | |||||||
| 						out expires)) | 						out expires)) | ||||||
| 						expires = DateTime.Now; | 						expires = DateTime.Now; | ||||||
|  |  | ||||||
| 					if (!cookie.IsNull () && cookie.Expires == DateTime.MinValue) | 					if (cookie != null && cookie.Expires == DateTime.MinValue) | ||||||
| 						cookie.Expires = expires.ToLocalTime (); | 						cookie.Expires = expires.ToLocalTime (); | ||||||
| 				} | 				} | ||||||
| 				else if (pair.StartsWith ("max-age", StringComparison.InvariantCultureIgnoreCase)) { | 				else if (pair.StartsWith ("max-age", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| 					int max = Int32.Parse (pair.GetValueInternal ("=").Trim ('"')); | 					int max = Int32.Parse (pair.GetValueInternal ("=").Trim ('"')); | ||||||
| 					var expires = DateTime.Now.AddSeconds ((double) max); | 					var expires = DateTime.Now.AddSeconds ((double) max); | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookie.Expires = expires; | 						cookie.Expires = expires; | ||||||
| 				} | 				} | ||||||
| 				else if (pair.StartsWith ("path", StringComparison.InvariantCultureIgnoreCase)) { | 				else if (pair.StartsWith ("path", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookie.Path = pair.GetValueInternal ("="); | 						cookie.Path = pair.GetValueInternal ("="); | ||||||
| 				} | 				} | ||||||
| 				else if (pair.StartsWith ("domain", StringComparison.InvariantCultureIgnoreCase)) { | 				else if (pair.StartsWith ("domain", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookie.Domain = pair.GetValueInternal ("="); | 						cookie.Domain = pair.GetValueInternal ("="); | ||||||
| 				} | 				} | ||||||
| 				else if (pair.StartsWith ("port", StringComparison.InvariantCultureIgnoreCase)) { | 				else if (pair.StartsWith ("port", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| @@ -321,31 +321,31 @@ namespace WebSocketSharp.Net { | |||||||
| 					         ? "\"\"" | 					         ? "\"\"" | ||||||
| 					         : pair.GetValueInternal ("="); | 					         : pair.GetValueInternal ("="); | ||||||
|  |  | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookie.Port = port; | 						cookie.Port = port; | ||||||
| 				} | 				} | ||||||
| 				else if (pair.StartsWith ("comment", StringComparison.InvariantCultureIgnoreCase)) { | 				else if (pair.StartsWith ("comment", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookie.Comment = pair.GetValueInternal ("=").UrlDecode (); | 						cookie.Comment = pair.GetValueInternal ("=").UrlDecode (); | ||||||
| 				} | 				} | ||||||
| 				else if (pair.StartsWith ("commenturl", StringComparison.InvariantCultureIgnoreCase)) { | 				else if (pair.StartsWith ("commenturl", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookie.CommentUri = pair.GetValueInternal ("=").Trim ('"').ToUri (); | 						cookie.CommentUri = pair.GetValueInternal ("=").Trim ('"').ToUri (); | ||||||
| 				} | 				} | ||||||
| 				else if (pair.StartsWith ("discard", StringComparison.InvariantCultureIgnoreCase)) { | 				else if (pair.StartsWith ("discard", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookie.Discard = true; | 						cookie.Discard = true; | ||||||
| 				} | 				} | ||||||
| 				else if (pair.StartsWith ("secure", StringComparison.InvariantCultureIgnoreCase)) { | 				else if (pair.StartsWith ("secure", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookie.Secure = true; | 						cookie.Secure = true; | ||||||
| 				} | 				} | ||||||
| 				else if (pair.StartsWith ("httponly", StringComparison.InvariantCultureIgnoreCase)) { | 				else if (pair.StartsWith ("httponly", StringComparison.InvariantCultureIgnoreCase)) { | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookie.HttpOnly = true; | 						cookie.HttpOnly = true; | ||||||
| 				} | 				} | ||||||
| 				else { | 				else { | ||||||
| 					if (!cookie.IsNull ()) | 					if (cookie != null) | ||||||
| 						cookies.Add (cookie); | 						cookies.Add (cookie); | ||||||
|  |  | ||||||
| 					string name; | 					string name; | ||||||
| @@ -366,7 +366,7 @@ namespace WebSocketSharp.Net { | |||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			if (!cookie.IsNull ()) | 			if (cookie != null) | ||||||
| 				cookies.Add (cookie); | 				cookies.Add (cookie); | ||||||
|  |  | ||||||
| 			return cookies; | 			return cookies; | ||||||
| @@ -457,7 +457,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		/// </exception> | 		/// </exception> | ||||||
| 		public void Add (Cookie cookie)  | 		public void Add (Cookie cookie)  | ||||||
| 		{ | 		{ | ||||||
| 			if (cookie.IsNull ()) | 			if (cookie == null) | ||||||
| 				throw new ArgumentNullException ("cookie"); | 				throw new ArgumentNullException ("cookie"); | ||||||
|  |  | ||||||
| 			int pos = SearchCookie (cookie); | 			int pos = SearchCookie (cookie); | ||||||
| @@ -478,7 +478,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		/// </exception> | 		/// </exception> | ||||||
| 		public void Add (CookieCollection cookies)  | 		public void Add (CookieCollection cookies)  | ||||||
| 		{ | 		{ | ||||||
| 			if (cookies.IsNull ()) | 			if (cookies == null) | ||||||
| 				throw new ArgumentNullException ("cookies"); | 				throw new ArgumentNullException ("cookies"); | ||||||
|  |  | ||||||
| 			foreach (Cookie cookie in cookies) | 			foreach (Cookie cookie in cookies) | ||||||
| @@ -519,7 +519,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		/// </exception> | 		/// </exception> | ||||||
| 		public void CopyTo (Array array, int index) | 		public void CopyTo (Array array, int index) | ||||||
| 		{ | 		{ | ||||||
| 			if (array.IsNull ()) | 			if (array == null) | ||||||
| 				throw new ArgumentNullException ("array"); | 				throw new ArgumentNullException ("array"); | ||||||
|  |  | ||||||
| 			if (index < 0) | 			if (index < 0) | ||||||
| @@ -561,7 +561,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		/// </exception> | 		/// </exception> | ||||||
| 		public void CopyTo (Cookie [] array, int index) | 		public void CopyTo (Cookie [] array, int index) | ||||||
| 		{ | 		{ | ||||||
| 			if (array.IsNull ()) | 			if (array == null) | ||||||
| 				throw new ArgumentNullException ("array"); | 				throw new ArgumentNullException ("array"); | ||||||
|  |  | ||||||
| 			if (index < 0) | 			if (index < 0) | ||||||
|   | |||||||
| @@ -36,8 +36,8 @@ using System.Linq; | |||||||
| using System.Net; | using System.Net; | ||||||
| using System.Text; | using System.Text; | ||||||
|  |  | ||||||
| namespace WebSocketSharp.Net { | namespace WebSocketSharp.Net | ||||||
|  | { | ||||||
| 	/// <summary> | 	/// <summary> | ||||||
| 	/// Provides access to a response to a request being processed by a <see cref="HttpListener"/> instance. | 	/// Provides access to a response to a request being processed by a <see cref="HttpListener"/> instance. | ||||||
| 	/// </summary> | 	/// </summary> | ||||||
| @@ -184,10 +184,10 @@ namespace WebSocketSharp.Net { | |||||||
| 				if (HeadersSent) | 				if (HeadersSent) | ||||||
| 					throw new InvalidOperationException ("Cannot be changed after headers are sent."); | 					throw new InvalidOperationException ("Cannot be changed after headers are sent."); | ||||||
|  |  | ||||||
| 				if (value.IsNull ()) | 				if (value == null) | ||||||
| 					throw new ArgumentNullException ("value"); | 					throw new ArgumentNullException ("value"); | ||||||
|  |  | ||||||
| 				if (value.IsEmpty ()) | 				if (value.Length == 0) | ||||||
| 					throw new ArgumentException ("Must not be empty.", "value"); | 					throw new ArgumentException ("Must not be empty.", "value"); | ||||||
|  |  | ||||||
| 				content_type = value; | 				content_type = value; | ||||||
| @@ -342,7 +342,7 @@ namespace WebSocketSharp.Net { | |||||||
| 				if (HeadersSent) | 				if (HeadersSent) | ||||||
| 					throw new InvalidOperationException ("Cannot be changed after headers are sent."); | 					throw new InvalidOperationException ("Cannot be changed after headers are sent."); | ||||||
|  |  | ||||||
| 				if (value.IsEmpty ()) | 				if (value.Length == 0) | ||||||
| 					throw new ArgumentException ("Must not be empty.", "value"); | 					throw new ArgumentException ("Must not be empty.", "value"); | ||||||
|  |  | ||||||
| 				location = value; | 				location = value; | ||||||
| @@ -758,7 +758,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		/// </exception> | 		/// </exception> | ||||||
| 		public void SetCookie (Cookie cookie) | 		public void SetCookie (Cookie cookie) | ||||||
| 		{ | 		{ | ||||||
| 			if (cookie.IsNull()) | 			if (cookie == null) | ||||||
| 				throw new ArgumentNullException ("cookie"); | 				throw new ArgumentNullException ("cookie"); | ||||||
|  |  | ||||||
| 			if (!CanAddOrUpdate (cookie)) | 			if (!CanAddOrUpdate (cookie)) | ||||||
|   | |||||||
| @@ -43,15 +43,15 @@ using System.Runtime.Serialization; | |||||||
| using System.Security.Permissions; | using System.Security.Permissions; | ||||||
| using System.Text; | using System.Text; | ||||||
|          |          | ||||||
| namespace WebSocketSharp.Net { | namespace WebSocketSharp.Net | ||||||
|  | { | ||||||
| 	/// <summary> | 	/// <summary> | ||||||
| 	/// Provides a collection of the HTTP headers associated with a request or response. | 	/// Provides a collection of the HTTP headers associated with a request or response. | ||||||
| 	/// </summary> | 	/// </summary> | ||||||
| 	[Serializable] | 	[Serializable] | ||||||
| 	[ComVisible (true)] | 	[ComVisible (true)] | ||||||
| 	public class WebHeaderCollection : NameValueCollection, ISerializable { | 	public class WebHeaderCollection : NameValueCollection, ISerializable | ||||||
|  | 	{ | ||||||
| 		#region Fields | 		#region Fields | ||||||
|  |  | ||||||
| 		static readonly Dictionary<string, HttpHeaderInfo> headers; | 		static readonly Dictionary<string, HttpHeaderInfo> headers; | ||||||
| @@ -275,7 +275,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		protected WebHeaderCollection ( | 		protected WebHeaderCollection ( | ||||||
| 			SerializationInfo serializationInfo, StreamingContext streamingContext) | 			SerializationInfo serializationInfo, StreamingContext streamingContext) | ||||||
| 		{ | 		{ | ||||||
| 			if (serializationInfo.IsNull ()) | 			if (serializationInfo == null) | ||||||
| 				throw new ArgumentNullException ("serializationInfo"); | 				throw new ArgumentNullException ("serializationInfo"); | ||||||
|  |  | ||||||
| 			try { | 			try { | ||||||
| @@ -582,9 +582,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		static bool TryGetHeaderInfo (string name, out HttpHeaderInfo info) | 		static bool TryGetHeaderInfo (string name, out HttpHeaderInfo info) | ||||||
| 		{ | 		{ | ||||||
| 			info = GetHeaderInfo (name); | 			info = GetHeaderInfo (name); | ||||||
| 			return info.IsNull () | 			return info != null; | ||||||
| 			       ? false |  | ||||||
| 			       : true; |  | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		#endregion | 		#endregion | ||||||
| @@ -932,7 +930,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		public override string [] GetValues (string header) | 		public override string [] GetValues (string header) | ||||||
| 		{ | 		{ | ||||||
| 			string [] values = base.GetValues (header); | 			string [] values = base.GetValues (header); | ||||||
| 			return values.IsNull () || values.Length == 0 | 			return values == null || values.Length == 0 | ||||||
| 			       ? null | 			       ? null | ||||||
| 			       : values; | 			       : values; | ||||||
| 		} | 		} | ||||||
| @@ -949,7 +947,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		public override string [] GetValues (int index) | 		public override string [] GetValues (int index) | ||||||
| 		{ | 		{ | ||||||
| 			string [] values = base.GetValues (index); | 			string [] values = base.GetValues (index); | ||||||
| 			return values.IsNull () || values.Length == 0 | 			return values == null || values.Length == 0 | ||||||
| 			       ? null | 			       ? null | ||||||
| 			       : values; | 			       : values; | ||||||
| 		} | 		} | ||||||
| @@ -971,7 +969,7 @@ namespace WebSocketSharp.Net { | |||||||
| 		public override void GetObjectData ( | 		public override void GetObjectData ( | ||||||
| 			SerializationInfo serializationInfo, StreamingContext streamingContext) | 			SerializationInfo serializationInfo, StreamingContext streamingContext) | ||||||
| 		{ | 		{ | ||||||
| 			if (serializationInfo.IsNull ()) | 			if (serializationInfo == null) | ||||||
| 				throw new ArgumentNullException ("serializationInfo"); | 				throw new ArgumentNullException ("serializationInfo"); | ||||||
|  |  | ||||||
| 			serializationInfo.AddValue ("InternallyCreated", internallyCreated); | 			serializationInfo.AddValue ("InternallyCreated", internallyCreated); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user