Refactored Ext.cs

This commit is contained in:
sta 2014-02-21 16:46:16 +09:00
parent 1548112965
commit 78261ff71c

View File

@ -2,11 +2,11 @@
/* /*
* Ext.cs * Ext.cs
* *
* Some part of this code are derived from Mono (http://www.mono-project.com). * Some parts of this code are derived from Mono (http://www.mono-project.com):
* * - GetStatusDescription is derived from System.Net.HttpListenerResponse.cs
* ParseBasicAuthResponseParams is derived from System.Net.HttpListenerContext.cs * - IsPredefinedScheme is derived from System.Uri.cs
* GetStatusDescription is derived from System.Net.HttpListenerResponse.cs * - MaybeUri is derived from System.Uri.cs
* IsPredefinedScheme and MaybeUri are derived from System.Uri.cs * - ParseBasicAuthResponseParams is derived from System.Net.HttpListenerContext.cs
* *
* The MIT License * The MIT License
* *
@ -42,7 +42,6 @@ using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq;
using System.Net.Sockets; using System.Net.Sockets;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using System.Text; using System.Text;
@ -131,8 +130,7 @@ namespace WebSocketSharp
} }
} }
private static byte [] readBytes ( private static byte [] readBytes (this Stream stream, byte [] buffer, int offset, int length)
this Stream stream, byte [] buffer, int offset, int length)
{ {
var len = stream.Read (buffer, offset, length); var len = stream.Read (buffer, offset, length);
if (len < 1) if (len < 1)
@ -250,8 +248,7 @@ namespace WebSocketSharp
: null; : null;
} }
internal static string CheckIfValidControlData ( internal static string CheckIfValidControlData (this byte [] data, string paramName)
this byte [] data, string paramName)
{ {
return data.Length > 125 return data.Length > 125
? String.Format ("'{0}' length must be less.", paramName) ? String.Format ("'{0}' length must be less.", paramName)
@ -261,8 +258,7 @@ namespace WebSocketSharp
internal static string CheckIfValidProtocols (this string [] protocols) internal static string CheckIfValidProtocols (this string [] protocols)
{ {
return protocols.Contains ( return protocols.Contains (
protocol => protocol => protocol == null || protocol.Length == 0 || !protocol.IsToken ())
protocol == null || protocol.Length == 0 || !protocol.IsToken ())
? "Contains an invalid value." ? "Contains an invalid value."
: protocols.ContainsTwice () : protocols.ContainsTwice ()
? "Contains a value twice." ? "Contains a value twice."
@ -308,8 +304,7 @@ namespace WebSocketSharp
: null; : null;
} }
internal static void Close ( internal static void Close (this HttpListenerResponse response, HttpStatusCode code)
this HttpListenerResponse response, HttpStatusCode code)
{ {
response.StatusCode = (int) code; response.StatusCode = (int) code;
response.OutputStream.Close (); response.OutputStream.Close ();
@ -322,8 +317,7 @@ namespace WebSocketSharp
response.Close (HttpStatusCode.Unauthorized); response.Close (HttpStatusCode.Unauthorized);
} }
internal static byte [] Compress ( internal static byte [] Compress (this byte [] value, CompressionMethod method)
this byte [] value, CompressionMethod method)
{ {
return method == CompressionMethod.DEFLATE return method == CompressionMethod.DEFLATE
? value.compress () ? value.compress ()
@ -337,16 +331,14 @@ namespace WebSocketSharp
: stream; : stream;
} }
internal static byte [] CompressToArray ( internal static byte [] CompressToArray (this Stream stream, CompressionMethod method)
this Stream stream, CompressionMethod method)
{ {
return method == CompressionMethod.DEFLATE return method == CompressionMethod.DEFLATE
? stream.compressToArray () ? stream.compressToArray ()
: stream.ToByteArray (); : stream.ToByteArray ();
} }
internal static bool Contains<T> ( internal static bool Contains<T> (this IEnumerable<T> source, Func<T, bool> comparer)
this IEnumerable<T> source, Func<T, bool> comparer)
{ {
foreach (T value in source) foreach (T value in source)
if (comparer (value)) if (comparer (value))
@ -388,8 +380,7 @@ namespace WebSocketSharp
src.CopyTo (dest, false); src.CopyTo (dest, false);
} }
internal static void CopyTo ( internal static void CopyTo (this Stream src, Stream dest, bool setDefaultPosition)
this Stream src, Stream dest, bool setDefaultPosition)
{ {
var readLen = 0; var readLen = 0;
var bufferLen = 256; var bufferLen = 256;
@ -402,24 +393,21 @@ namespace WebSocketSharp
dest.Position = 0; dest.Position = 0;
} }
internal static byte [] Decompress ( internal static byte [] Decompress (this byte [] value, CompressionMethod method)
this byte [] value, CompressionMethod method)
{ {
return method == CompressionMethod.DEFLATE return method == CompressionMethod.DEFLATE
? value.decompress () ? value.decompress ()
: value; : value;
} }
internal static Stream Decompress ( internal static Stream Decompress (this Stream stream, CompressionMethod method)
this Stream stream, CompressionMethod method)
{ {
return method == CompressionMethod.DEFLATE return method == CompressionMethod.DEFLATE
? stream.decompress () ? stream.decompress ()
: stream; : stream;
} }
internal static byte [] DecompressToArray ( internal static byte [] DecompressToArray (this Stream stream, CompressionMethod method)
this Stream stream, CompressionMethod method)
{ {
return method == CompressionMethod.DEFLATE return method == CompressionMethod.DEFLATE
? stream.decompressToArray () ? stream.decompressToArray ()
@ -427,9 +415,8 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Determines whether the specified <see cref="int"/> equals the specified /// Determines whether the specified <see cref="int"/> equals the specified <see cref="char"/>,
/// <see cref="char"/>, and invokes the specified Action&lt;int&gt; delegate /// and invokes the specified Action&lt;int&gt; delegate at the same time.
/// at the same time.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <c>true</c> if <paramref name="value"/> equals <paramref name="c"/>; /// <c>true</c> if <paramref name="value"/> equals <paramref name="c"/>;
@ -442,9 +429,9 @@ namespace WebSocketSharp
/// A <see cref="char"/> to compare. /// A <see cref="char"/> to compare.
/// </param> /// </param>
/// <param name="action"> /// <param name="action">
/// An Action&lt;int&gt; delegate that references the method(s) called at the /// An Action&lt;int&gt; delegate that references the method(s) called at
/// same time as comparing. An <see cref="int"/> parameter to pass to the /// the same time as comparing. An <see cref="int"/> parameter to pass to
/// method(s) is <paramref name="value"/>. /// the method(s) is <paramref name="value"/>.
/// </param> /// </param>
/// <exception cref="ArgumentOutOfRangeException"> /// <exception cref="ArgumentOutOfRangeException">
/// <paramref name="value"/> isn't between 0 and 255. /// <paramref name="value"/> isn't between 0 and 255.
@ -462,8 +449,8 @@ 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 represents the absolute path if it's /// A <see cref="string"/> that represents the absolute path if it's successfully found;
/// successfully found; otherwise, <see langword="null"/>. /// otherwise, <see langword="null"/>.
/// </returns> /// </returns>
/// <param name="uri"> /// <param name="uri">
/// A <see cref="Uri"/> that represents a URI to get the absolute path from. /// A <see cref="Uri"/> that represents a URI to get the absolute path from.
@ -506,19 +493,17 @@ namespace WebSocketSharp
: String.Empty; : String.Empty;
} }
internal static string GetNameInternal ( internal static string GetNameInternal (this string nameAndValue, string separator)
this string nameAndValue, string separator)
{ {
int i = nameAndValue.IndexOf (separator); var i = nameAndValue.IndexOf (separator);
return i > 0 return i > 0
? nameAndValue.Substring (0, i).Trim () ? nameAndValue.Substring (0, i).Trim ()
: null; : null;
} }
internal static string GetValueInternal ( internal static string GetValueInternal (this string nameAndValue, string separator)
this string nameAndValue, string separator)
{ {
int i = nameAndValue.IndexOf (separator); var i = nameAndValue.IndexOf (separator);
return i >= 0 && i < nameAndValue.Length - 1 return i >= 0 && i < nameAndValue.Length - 1
? nameAndValue.Substring (i + 1).Trim () ? nameAndValue.Substring (i + 1).Trim ()
: null; : null;
@ -558,8 +543,8 @@ namespace WebSocketSharp
internal static bool IsText (this string value) internal static bool IsText (this string value)
{ {
int len = value.Length; var len = value.Length;
for (int i = 0; i < len; i++) { for (var i = 0; i < len; i++) {
char c = value [i]; char c = value [i];
if (c < 0x20 && !"\r\n\t".Contains (c)) if (c < 0x20 && !"\r\n\t".Contains (c))
return false; return false;
@ -593,8 +578,7 @@ namespace WebSocketSharp
: String.Format ("\"{0}\"", value.Replace ("\"", "\\\"")); : String.Format ("\"{0}\"", value.Replace ("\"", "\\\""));
} }
internal static NameValueCollection ParseBasicAuthResponseParams ( internal static NameValueCollection ParseBasicAuthResponseParams (this string value)
this string value)
{ {
// HTTP Basic Authentication response is a formatted Base64 string. // HTTP Basic Authentication response is a formatted Base64 string.
var userPass = Encoding.Default.GetString ( var userPass = Encoding.Default.GetString (
@ -649,8 +633,7 @@ namespace WebSocketSharp
return stream.readBytes (new byte [length], 0, length); return stream.readBytes (new byte [length], 0, length);
} }
internal static byte [] ReadBytes ( internal static byte [] ReadBytes (this Stream stream, long length, int bufferLength)
this Stream stream, long length, int bufferLength)
{ {
using (var result = new MemoryStream ()) { using (var result = new MemoryStream ()) {
var count = length / bufferLength; var count = length / bufferLength;
@ -674,10 +657,7 @@ namespace WebSocketSharp
} }
internal static void ReadBytesAsync ( internal static void ReadBytesAsync (
this Stream stream, this Stream stream, int length, Action<byte []> completed, Action<Exception> error)
int length,
Action<byte []> completed,
Action<Exception> error)
{ {
var buffer = new byte [length]; var buffer = new byte [length];
stream.BeginRead ( stream.BeginRead (
@ -719,6 +699,18 @@ namespace WebSocketSharp
: value; : value;
} }
internal static T [] Reverse<T> (this T [] array)
{
var len = array.Length;
T [] reverse = new T [len];
var end = len - 1;
for (var i = 0; i <= end; i++)
reverse [i] = array [end - i];
return reverse;
}
internal static IEnumerable<string> SplitHeaderValue ( internal static IEnumerable<string> SplitHeaderValue (
this string value, params char [] separator) this string value, params char [] separator)
{ {
@ -771,22 +763,22 @@ namespace WebSocketSharp
} }
} }
internal static byte [] ToByteArrayInternally ( internal static byte [] ToByteArrayInternally (this ushort value, ByteOrder order)
this ushort value, ByteOrder order)
{ {
var buffer = BitConverter.GetBytes (value); var bytes = BitConverter.GetBytes (value);
return order.IsHostOrder () if (!order.IsHostOrder ())
? buffer Array.Reverse (bytes);
: buffer.Reverse ().ToArray ();
return bytes;
} }
internal static byte [] ToByteArrayInternally ( internal static byte [] ToByteArrayInternally (this ulong value, ByteOrder order)
this ulong value, ByteOrder order)
{ {
var buffer = BitConverter.GetBytes (value); var bytes = BitConverter.GetBytes (value);
return order.IsHostOrder () if (!order.IsHostOrder ())
? buffer Array.Reverse (bytes);
: buffer.Reverse ().ToArray ();
return bytes;
} }
internal static CompressionMethod ToCompressionMethod (this string value) internal static CompressionMethod ToCompressionMethod (this string value)
@ -805,8 +797,7 @@ namespace WebSocketSharp
: String.Empty; : String.Empty;
} }
internal static System.Net.IPAddress ToIPAddress ( internal static System.Net.IPAddress ToIPAddress (this string hostNameOrAddress)
this string hostNameOrAddress)
{ {
try { try {
var addrs = System.Net.Dns.GetHostAddresses (hostNameOrAddress); var addrs = System.Net.Dns.GetHostAddresses (hostNameOrAddress);
@ -845,21 +836,18 @@ namespace WebSocketSharp
/// <paramref name="uriString"/>. /// <paramref name="uriString"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <c>true</c> if a <see cref="Uri"/> is successfully created; otherwise, /// <c>true</c> if a <see cref="Uri"/> is successfully created; otherwise, <c>false</c>.
/// <c>false</c>.
/// </returns> /// </returns>
/// <param name="uriString"> /// <param name="uriString">
/// A <see cref="string"/> that represents the WebSocket URL to try. /// A <see cref="string"/> that represents the WebSocket URL to try.
/// </param> /// </param>
/// <param name="result"> /// <param name="result">
/// When this method returns, a <see cref="Uri"/> that represents the /// When this method returns, a <see cref="Uri"/> that represents the WebSocket URL if
/// WebSocket URL if <paramref name="uriString"/> is valid; otherwise, /// <paramref name="uriString"/> is valid; otherwise, <see langword="null"/>.
/// <see langword="null"/>.
/// </param> /// </param>
/// <param name="message"> /// <param name="message">
/// When this method returns, a <see cref="string"/> that represents the /// When this method returns, a <see cref="string"/> that represents the error message if
/// error message if <paramref name="uriString"/> is invalid; otherwise, /// <paramref name="uriString"/> is invalid; otherwise, <see cref="String.Empty"/>.
/// <see cref="String.Empty"/>.
/// </param> /// </param>
internal static bool TryCreateWebSocketUri ( internal static bool TryCreateWebSocketUri (
this string uriString, out Uri result, out string message) this string uriString, out Uri result, out string message)
@ -936,12 +924,12 @@ namespace WebSocketSharp
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// Determines whether the specified <see cref="string"/> contains any of /// Determines whether the specified <see cref="string"/> contains any of characters
/// characters 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 /// <c>true</c> if <paramref name="value"/> contains any of <paramref name="chars"/>;
/// <paramref name="chars"/>; otherwise, <c>false</c>. /// otherwise, <c>false</c>.
/// </returns> /// </returns>
/// <param name="value"> /// <param name="value">
/// A <see cref="string"/> to test. /// A <see cref="string"/> to test.
@ -959,12 +947,12 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Determines whether the specified <see cref="NameValueCollection"/> /// Determines whether the specified <see cref="NameValueCollection"/> contains the entry
/// contains the entry with the specified <paramref name="name"/>. /// with the specified <paramref name="name"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <c>true</c> if <paramref name="collection"/> contains the entry with /// <c>true</c> if <paramref name="collection"/> contains the entry
/// <paramref name="name"/>; otherwise, <c>false</c>. /// with <paramref name="name"/>; otherwise, <c>false</c>.
/// </returns> /// </returns>
/// <param name="collection"> /// <param name="collection">
/// A <see cref="NameValueCollection"/> to test. /// A <see cref="NameValueCollection"/> to test.
@ -980,13 +968,13 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Determines whether the specified <see cref="NameValueCollection"/> /// Determines whether the specified <see cref="NameValueCollection"/> contains the entry
/// contains the entry with the specified both <paramref name="name"/> and /// with the specified both <paramref name="name"/> and <paramref name="value"/>.
/// <paramref name="value"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <c>true</c> if <paramref name="collection"/> contains the entry with both /// <c>true</c> if <paramref name="collection"/> contains the entry
/// <paramref name="name"/> and <paramref name="value"/>; otherwise, <c>false</c>. /// with both <paramref name="name"/> and <paramref name="value"/>;
/// otherwise, <c>false</c>.
/// </returns> /// </returns>
/// <param name="collection"> /// <param name="collection">
/// A <see cref="NameValueCollection"/> to test. /// A <see cref="NameValueCollection"/> to test.
@ -997,8 +985,7 @@ namespace WebSocketSharp
/// <param name="value"> /// <param name="value">
/// A <see cref="string"/> that represents the value of the entry to find. /// A <see cref="string"/> that represents the value of the entry to find.
/// </param> /// </param>
public static bool Contains ( public static bool Contains (this NameValueCollection collection, string name, string value)
this NameValueCollection collection, string name, string value)
{ {
if (collection == null || collection.Count == 0) if (collection == null || collection.Count == 0)
return false; return false;
@ -1015,8 +1002,7 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Emits the specified <see cref="EventHandler"/> delegate if it isn't /// Emits the specified <see cref="EventHandler"/> delegate if it isn't <see langword="null"/>.
/// <see langword="null"/>.
/// </summary> /// </summary>
/// <param name="eventHandler"> /// <param name="eventHandler">
/// A <see cref="EventHandler"/> to emit. /// A <see cref="EventHandler"/> to emit.
@ -1027,16 +1013,15 @@ namespace WebSocketSharp
/// <param name="e"> /// <param name="e">
/// A <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)
{ {
if (eventHandler != null) if (eventHandler != null)
eventHandler (sender, e); eventHandler (sender, e);
} }
/// <summary> /// <summary>
/// Emits the specified <c>EventHandler&lt;TEventArgs&gt;</c> delegate if it /// Emits the specified <c>EventHandler&lt;TEventArgs&gt;</c> delegate
/// isn't <see langword="null"/>. /// if it isn't <see langword="null"/>.
/// </summary> /// </summary>
/// <param name="eventHandler"> /// <param name="eventHandler">
/// An <c>EventHandler&lt;TEventArgs&gt;</c> to emit. /// An <c>EventHandler&lt;TEventArgs&gt;</c> to emit.
@ -1059,23 +1044,19 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Gets the collection of the HTTP Cookies from the specified HTTP /// Gets the collection of the HTTP cookies from the specified HTTP <paramref name="headers"/>.
/// <paramref name="headers"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// A <see cref="CookieCollection"/> that receives a collection of the HTTP /// A <see cref="CookieCollection"/> that receives a collection of the HTTP cookies.
/// Cookies.
/// </returns> /// </returns>
/// <param name="headers"> /// <param name="headers">
/// A <see cref="NameValueCollection"/> that contains a collection of the HTTP /// A <see cref="NameValueCollection"/> that contains a collection of the HTTP headers.
/// Headers.
/// </param> /// </param>
/// <param name="response"> /// <param name="response">
/// <c>true</c> if <paramref name="headers"/> is a collection of the response /// <c>true</c> if <paramref name="headers"/> is a collection of the response headers;
/// headers; otherwise, <c>false</c>. /// otherwise, <c>false</c>.
/// </param> /// </param>
public static CookieCollection GetCookies ( public static CookieCollection GetCookies (this NameValueCollection headers, bool response)
this NameValueCollection headers, bool response)
{ {
var name = response ? "Set-Cookie" : "Cookie"; var name = response ? "Set-Cookie" : "Cookie";
return headers == null || !headers.Contains (name) return headers == null || !headers.Contains (name)
@ -1087,12 +1068,10 @@ namespace WebSocketSharp
/// Gets the description of the specified HTTP status <paramref name="code"/>. /// Gets the description of the specified HTTP status <paramref name="code"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// A <see cref="string"/> that represents the description of the HTTP status /// A <see cref="string"/> that represents the description of the HTTP status code.
/// code.
/// </returns> /// </returns>
/// <param name="code"> /// <param name="code">
/// One of <see cref="HttpStatusCode"/> values that indicate the HTTP status /// One of <see cref="HttpStatusCode"/> enum values, indicates the HTTP status codes.
/// codes.
/// </param> /// </param>
public static string GetDescription (this HttpStatusCode code) public static string GetDescription (this HttpStatusCode code)
{ {
@ -1100,16 +1079,15 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Gets the name from the specified <see cref="string"/> that contains a pair /// Gets the name from the specified <see cref="string"/> that contains a pair of name and
/// of name and value separated by a separator string. /// value separated by a separator string.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// A <see cref="string"/> that represents the name if any; otherwise, /// A <see cref="string"/> that represents the name if any; otherwise, <c>null</c>.
/// <c>null</c>.
/// </returns> /// </returns>
/// <param name="nameAndValue"> /// <param name="nameAndValue">
/// A <see cref="string"/> that contains a pair of name and value separated by /// A <see cref="string"/> that contains a pair of name and value separated by a separator
/// a separator string. /// string.
/// </param> /// </param>
/// <param name="separator"> /// <param name="separator">
/// A <see cref="string"/> that represents a separator string. /// A <see cref="string"/> that represents a separator string.
@ -1123,16 +1101,15 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Gets the name and value from the specified <see cref="string"/> that /// Gets the name and value from the specified <see cref="string"/> that contains a pair of
/// contains a pair of name and value separated by a separator string. /// name and value separated by a separator string.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// A <c>KeyValuePair&lt;string, string&gt;</c> that represents the name and /// A <c>KeyValuePair&lt;string, string&gt;</c> that represents the name and value if any.
/// value if any.
/// </returns> /// </returns>
/// <param name="nameAndValue"> /// <param name="nameAndValue">
/// A <see cref="string"/> that contains a pair of name and value separated by /// A <see cref="string"/> that contains a pair of name and value separated by a separator
/// a separator string. /// string.
/// </param> /// </param>
/// <param name="separator"> /// <param name="separator">
/// A <see cref="string"/> that represents a separator string. /// A <see cref="string"/> that represents a separator string.
@ -1151,8 +1128,7 @@ namespace WebSocketSharp
/// Gets the description of the specified HTTP status <paramref name="code"/>. /// Gets the description of the specified HTTP status <paramref name="code"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// A <see cref="string"/> that represents the description of the HTTP status /// A <see cref="string"/> that represents the description of the HTTP status code.
/// code.
/// </returns> /// </returns>
/// <param name="code"> /// <param name="code">
/// An <see cref="int"/> that represents the HTTP status code. /// An <see cref="int"/> that represents the HTTP status code.
@ -1212,16 +1188,15 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Gets the value from the specified <see cref="string"/> that contains /// Gets the value from the specified <see cref="string"/> that contains a pair of name and
/// a pair of name and value separated by a separator string. /// value separated by a separator string.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// A <see cref="string"/> that represents the value if any; otherwise, /// A <see cref="string"/> that represents the value if any; otherwise, <c>null</c>.
/// <c>null</c>.
/// </returns> /// </returns>
/// <param name="nameAndValue"> /// <param name="nameAndValue">
/// A <see cref="string"/> that contains a pair of name and value separated by /// A <see cref="string"/> that contains a pair of name and value separated by a separator
/// a separator string. /// string.
/// </param> /// </param>
/// <param name="separator"> /// <param name="separator">
/// A <see cref="string"/> that represents a separator string. /// A <see cref="string"/> that represents a separator string.
@ -1235,8 +1210,8 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Determines whether the specified <see cref="ushort"/> is in the allowable /// Determines whether the specified <see cref="ushort"/> is in the allowable range of
/// range of the WebSocket close status code. /// the WebSocket close status code.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Not allowable ranges are the followings. /// Not allowable ranges are the followings.
@ -1248,15 +1223,14 @@ namespace WebSocketSharp
/// </item> /// </item>
/// <item> /// <item>
/// <term> /// <term>
/// Numbers which are greater than 4999 are out of the reserved close /// Numbers greater than 4999 are out of the reserved close status code ranges.
/// status code ranges.
/// </term> /// </term>
/// </item> /// </item>
/// </list> /// </list>
/// </remarks> /// </remarks>
/// <returns> /// <returns>
/// <c>true</c> if <paramref name="value"/> is in the allowable range of the /// <c>true</c> if <paramref name="value"/> is in the allowable range of the WebSocket
/// WebSocket close status code; otherwise, <c>false</c>. /// close status code; otherwise, <c>false</c>.
/// </returns> /// </returns>
/// <param name="value"> /// <param name="value">
/// A <see cref="ushort"/> to test. /// A <see cref="ushort"/> to test.
@ -1267,8 +1241,8 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Determines whether the specified <see cref="string"/> is enclosed in the /// Determines whether the specified <see cref="string"/> is enclosed in the specified
/// specified <see cref="char"/>. /// <see cref="char"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <c>true</c> if <paramref name="value"/> is enclosed in <paramref name="c"/>; /// <c>true</c> if <paramref name="value"/> is enclosed in <paramref name="c"/>;
@ -1289,15 +1263,15 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Determines whether the specified <see cref="ByteOrder"/> is host (this /// Determines whether the specified <see cref="ByteOrder"/> is host
/// computer architecture) byte order. /// (this computer architecture) byte order.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <c>true</c> if <paramref name="order"/> is host byte order; otherwise, /// <c>true</c> if <paramref name="order"/> is host byte order;
/// <c>false</c>. /// otherwise, <c>false</c>.
/// </returns> /// </returns>
/// <param name="order"> /// <param name="order">
/// A <see cref="ByteOrder"/> to test. /// One of the <see cref="ByteOrder"/> enum values, to test.
/// </param> /// </param>
public static bool IsHostOrder (this ByteOrder order) public static bool IsHostOrder (this ByteOrder order)
{ {
@ -1307,8 +1281,8 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Determines whether the specified <see cref="System.Net.IPAddress"/> /// Determines whether the specified <see cref="System.Net.IPAddress"/> represents
/// represents the local IP address. /// the local IP address.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <c>true</c> if <paramref name="address"/> represents the local IP address; /// <c>true</c> if <paramref name="address"/> represents the local IP address;
@ -1325,8 +1299,7 @@ namespace WebSocketSharp
if (address == null) if (address == null)
throw new ArgumentNullException ("address"); throw new ArgumentNullException ("address");
if (address.Equals (System.Net.IPAddress.Any) || if (address.Equals (System.Net.IPAddress.Any) || System.Net.IPAddress.IsLoopback (address))
System.Net.IPAddress.IsLoopback (address))
return true; return true;
var host = System.Net.Dns.GetHostName (); var host = System.Net.Dns.GetHostName ();
@ -1339,12 +1312,11 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Determines whether the specified <see cref="string"/> is /// Determines whether the specified <see cref="string"/> is <see langword="null"/> or empty.
/// <see langword="null"/> or empty.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <c>true</c> if <paramref name="value"/> is <see langword="null"/> or /// <c>true</c> if <paramref name="value"/> is <see langword="null"/> or empty;
/// empty; otherwise, <c>false</c>. /// otherwise, <c>false</c>.
/// </returns> /// </returns>
/// <param name="value"> /// <param name="value">
/// A <see cref="string"/> to test. /// A <see cref="string"/> to test.
@ -1355,12 +1327,10 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Determines whether the specified <see cref="string"/> is a predefined /// Determines whether the specified <see cref="string"/> is a predefined scheme.
/// scheme.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <c>true</c> if <paramref name="value"/> is a predefined scheme; otherwise, /// <c>true</c> if <paramref name="value"/> is a predefined scheme; otherwise, <c>false</c>.
/// <c>false</c>.
/// </returns> /// </returns>
/// <param name="value"> /// <param name="value">
/// A <see cref="string"/> to test. /// A <see cref="string"/> to test.
@ -1391,12 +1361,12 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Determines whether the specified <see cref="HttpListenerRequest"/> is an /// Determines whether the specified <see cref="HttpListenerRequest"/> is an HTTP Upgrade
/// HTTP Upgrade request to switch to the specified <paramref name="protocol"/>. /// request to switch to the specified <paramref name="protocol"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <c>true</c> if <paramref name="request"/> is an HTTP Upgrade request to /// <c>true</c> if <paramref name="request"/> is an HTTP Upgrade request to switch to
/// switch to <paramref name="protocol"/>; otherwise, <c>false</c>. /// <paramref name="protocol"/>; otherwise, <c>false</c>.
/// </returns> /// </returns>
/// <param name="request"> /// <param name="request">
/// A <see cref="HttpListenerRequest"/> that represents the HTTP request. /// A <see cref="HttpListenerRequest"/> that represents the HTTP request.
@ -1418,8 +1388,7 @@ namespace WebSocketSharp
/// <exception cref="ArgumentException"> /// <exception cref="ArgumentException">
/// <paramref name="protocol"/> is empty. /// <paramref name="protocol"/> is empty.
/// </exception> /// </exception>
public static bool IsUpgradeTo ( public static bool IsUpgradeTo (this HttpListenerRequest request, string protocol)
this HttpListenerRequest request, string protocol)
{ {
if (request == null) if (request == null)
throw new ArgumentNullException ("request"); throw new ArgumentNullException ("request");
@ -1438,8 +1407,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 <paramref name="value"/> is maybe a URI string; otherwise, /// <c>true</c> if <paramref name="value"/> is maybe a URI string; otherwise, <c>false</c>.
/// <c>false</c>.
/// </returns> /// </returns>
/// <param name="value"> /// <param name="value">
/// A <see cref="string"/> to test. /// A <see cref="string"/> to test.
@ -1464,19 +1432,18 @@ namespace WebSocketSharp
/// A sub-array starts at the specified element position. /// 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 /// An array of T that receives a sub-array, or an empty array of T if any problems
/// problems with the parameters. /// with the parameters.
/// </returns> /// </returns>
/// <param name="array"> /// <param name="array">
/// 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 /// An <see cref="int"/> that contains the zero-based starting position of a sub-array
/// a sub-array in <paramref name="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 /// An <see cref="int"/> that contains the number of elements to retrieve a sub-array.
/// a sub-array.
/// </param> /// </param>
/// <typeparam name="T"> /// <typeparam name="T">
/// The type of elements in the <paramref name="array"/>. /// The type of elements in the <paramref name="array"/>.
@ -1502,8 +1469,7 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Executes the specified <see cref="Action"/> delegate <paramref name="n"/> /// Executes the specified <see cref="Action"/> delegate <paramref name="n"/> times.
/// times.
/// </summary> /// </summary>
/// <param name="n"> /// <param name="n">
/// An <see cref="int"/> is the number of times to execute. /// An <see cref="int"/> is the number of times to execute.
@ -1518,8 +1484,7 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Executes the specified <see cref="Action"/> delegate <paramref name="n"/> /// Executes the specified <see cref="Action"/> delegate <paramref name="n"/> times.
/// times.
/// </summary> /// </summary>
/// <param name="n"> /// <param name="n">
/// A <see cref="long"/> is the number of times to execute. /// A <see cref="long"/> is the number of times to execute.
@ -1534,8 +1499,7 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Executes the specified <see cref="Action"/> delegate <paramref name="n"/> /// Executes the specified <see cref="Action"/> delegate <paramref name="n"/> times.
/// times.
/// </summary> /// </summary>
/// <param name="n"> /// <param name="n">
/// A <see cref="uint"/> is the number of times to execute. /// A <see cref="uint"/> is the number of times to execute.
@ -1550,8 +1514,7 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Executes the specified <see cref="Action"/> delegate <paramref name="n"/> /// Executes the specified <see cref="Action"/> delegate <paramref name="n"/> times.
/// times.
/// </summary> /// </summary>
/// <param name="n"> /// <param name="n">
/// A <see cref="ulong"/> is the number of times to execute. /// A <see cref="ulong"/> is the number of times to execute.
@ -1566,16 +1529,15 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Executes the specified <c>Action&lt;int&gt;</c> delegate /// Executes the specified <c>Action&lt;int&gt;</c> delegate <paramref name="n"/> times.
/// <paramref name="n"/> times.
/// </summary> /// </summary>
/// <param name="n"> /// <param name="n">
/// An <see cref="int"/> is the number of times to execute. /// An <see cref="int"/> is the number of times to execute.
/// </param> /// </param>
/// <param name="act"> /// <param name="act">
/// An <c>Action&lt;int&gt;</c> delegate that references the method(s) to /// An <c>Action&lt;int&gt;</c> delegate that references the method(s) to execute.
/// execute. An <see cref="int"/> parameter to pass to the method(s) is the /// An <see cref="int"/> parameter to pass to the method(s) is the zero-based count
/// zero-based count of iteration. /// of iteration.
/// </param> /// </param>
public static void Times (this int n, Action<int> act) public static void Times (this int n, Action<int> act)
{ {
@ -1585,16 +1547,15 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Executes the specified <c>Action&lt;long&gt;</c> delegate /// Executes the specified <c>Action&lt;long&gt;</c> delegate <paramref name="n"/> times.
/// <paramref name="n"/> times.
/// </summary> /// </summary>
/// <param name="n"> /// <param name="n">
/// A <see cref="long"/> is the number of times to execute. /// A <see cref="long"/> is the number of times to execute.
/// </param> /// </param>
/// <param name="act"> /// <param name="act">
/// An <c>Action&lt;long&gt;</c> delegate that references the method(s) to /// An <c>Action&lt;long&gt;</c> delegate that references the method(s) to execute.
/// execute. A <see cref="long"/> parameter to pass to the method(s) is the /// A <see cref="long"/> parameter to pass to the method(s) is the zero-based count
/// zero-based count of iteration. /// of iteration.
/// </param> /// </param>
public static void Times (this long n, Action<long> act) public static void Times (this long n, Action<long> act)
{ {
@ -1604,16 +1565,15 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Executes the specified <c>Action&lt;uint&gt;</c> delegate /// Executes the specified <c>Action&lt;uint&gt;</c> delegate <paramref name="n"/> times.
/// <paramref name="n"/> times.
/// </summary> /// </summary>
/// <param name="n"> /// <param name="n">
/// A <see cref="uint"/> is the number of times to execute. /// A <see cref="uint"/> is the number of times to execute.
/// </param> /// </param>
/// <param name="act"> /// <param name="act">
/// An <c>Action&lt;uint&gt;</c> delegate that references the method(s) to /// An <c>Action&lt;uint&gt;</c> delegate that references the method(s) to execute.
/// execute. A <see cref="uint"/> parameter to pass to the method(s) is the /// A <see cref="uint"/> parameter to pass to the method(s) is the zero-based count
/// zero-based count of iteration. /// of iteration.
/// </param> /// </param>
public static void Times (this uint n, Action<uint> act) public static void Times (this uint n, Action<uint> act)
{ {
@ -1623,16 +1583,15 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Executes the specified <c>Action&lt;ulong&gt;</c> delegate /// Executes the specified <c>Action&lt;ulong&gt;</c> delegate <paramref name="n"/> times.
/// <paramref name="n"/> times.
/// </summary> /// </summary>
/// <param name="n"> /// <param name="n">
/// A <see cref="ulong"/> is the number of times to execute. /// A <see cref="ulong"/> is the number of times to execute.
/// </param> /// </param>
/// <param name="act"> /// <param name="act">
/// An <c>Action&lt;ulong&gt;</c> delegate that references the method(s) to /// An <c>Action&lt;ulong&gt;</c> delegate that references the method(s) to execute.
/// execute. A <see cref="ulong"/> parameter to pass to this method(s) is the /// A <see cref="ulong"/> parameter to pass to this method(s) is the zero-based count
/// zero-based count of iteration. /// of iteration.
/// </param> /// </param>
public static void Times (this ulong n, Action<ulong> act) public static void Times (this ulong n, Action<ulong> act)
{ {
@ -1642,21 +1601,20 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Converts the specified array of <see cref="byte"/> to the specified type /// Converts the specified array of <see cref="byte"/> to the specified type data.
/// data.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// A T converted from <paramref name="src"/>, or a default value of T if /// A T converted from <paramref name="src"/>, or a default value of T if
/// <paramref name="src"/> is an empty array of <see cref="byte"/> or if the /// <paramref name="src"/> is an empty array of <see cref="byte"/> or if the
/// type of T isn't <see cref="bool"/>, <see cref="char"/>, <see cref="double"/>, /// type of T isn't <see cref="bool"/>, <see cref="char"/>, <see cref="double"/>,
/// <see cref="float"/>, <see cref="int"/>, <see cref="long"/>, <see cref="short"/>, /// <see cref="float"/>, <see cref="int"/>, <see cref="long"/>, <see cref="short"/>,
/// <see cref="uint"/>, <see cref="ulong"/> or <see cref="ushort"/>. /// <see cref="uint"/>, <see cref="ulong"/>, or <see cref="ushort"/>.
/// </returns> /// </returns>
/// <param name="src"> /// <param name="src">
/// 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="ByteOrder"/> that indicates the byte order of /// One of the <see cref="ByteOrder"/> enum values, indicates the byte order of
/// <paramref name="src"/>. /// <paramref name="src"/>.
/// </param> /// </param>
/// <typeparam name="T"> /// <typeparam name="T">
@ -1701,8 +1659,7 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Converts the specified <paramref name="value"/> to an array of /// Converts the specified <paramref name="value"/> to an array of <see cref="byte"/>.
/// <see cref="byte"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// An array of <see cref="byte"/> converted from <paramref name="value"/>. /// An array of <see cref="byte"/> converted from <paramref name="value"/>.
@ -1711,7 +1668,7 @@ namespace WebSocketSharp
/// A T to convert. /// A T to convert.
/// </param> /// </param>
/// <param name="order"> /// <param name="order">
/// A <see cref="ByteOrder"/> that indicates the byte order of the return. /// One of the <see cref="ByteOrder"/> enum values, 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.
@ -1720,38 +1677,38 @@ namespace WebSocketSharp
where T : struct where T : struct
{ {
var type = typeof (T); var type = typeof (T);
var buffer = type == typeof (Boolean) var bytes = type == typeof (Boolean)
? BitConverter.GetBytes ((Boolean)(object) value) ? BitConverter.GetBytes ((Boolean)(object) value)
: type == typeof (Byte) : type == typeof (Byte)
? new byte [] { (Byte)(object) value } ? new byte [] { (Byte)(object) value }
: type == typeof (Char) : type == typeof (Char)
? BitConverter.GetBytes ((Char)(object) value) ? BitConverter.GetBytes ((Char)(object) value)
: type == typeof (Double) : type == typeof (Double)
? BitConverter.GetBytes ((Double)(object) value) ? BitConverter.GetBytes ((Double)(object) value)
: type == typeof (Int16) : type == typeof (Int16)
? BitConverter.GetBytes ((Int16)(object) value) ? BitConverter.GetBytes ((Int16)(object) value)
: type == typeof (Int32) : type == typeof (Int32)
? BitConverter.GetBytes ((Int32)(object) value) ? BitConverter.GetBytes ((Int32)(object) value)
: type == typeof (Int64) : type == typeof (Int64)
? BitConverter.GetBytes ((Int64)(object) value) ? BitConverter.GetBytes ((Int64)(object) value)
: type == typeof (Single) : type == typeof (Single)
? BitConverter.GetBytes ((Single)(object) value) ? BitConverter.GetBytes ((Single)(object) value)
: type == typeof (UInt16) : type == typeof (UInt16)
? BitConverter.GetBytes ((UInt16)(object) value) ? BitConverter.GetBytes ((UInt16)(object) value)
: type == typeof (UInt32) : type == typeof (UInt32)
? BitConverter.GetBytes ((UInt32)(object) value) ? BitConverter.GetBytes ((UInt32)(object) value)
: type == typeof (UInt64) : type == typeof (UInt64)
? BitConverter.GetBytes ((UInt64)(object) value) ? BitConverter.GetBytes ((UInt64)(object) value)
: new byte []{}; : new byte [0];
return buffer.Length <= 1 || order.IsHostOrder () if (bytes.Length > 1 && !order.IsHostOrder ())
? buffer Array.Reverse (bytes);
: buffer.Reverse ().ToArray ();
return bytes;
} }
/// <summary> /// <summary>
/// Converts the order of the specified array of <see cref="byte"/> to the /// Converts the order of the specified array of <see cref="byte"/> to the host byte order.
/// host byte order.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// An array of <see cref="byte"/> converted from <paramref name="src"/>. /// An array of <see cref="byte"/> converted from <paramref name="src"/>.
@ -1760,7 +1717,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">
/// One of <see cref="ByteOrder"/> values that indicate the byte order of /// One of the <see cref="ByteOrder"/> enum values, indicates the byte order of
/// <paramref name="src"/>. /// <paramref name="src"/>.
/// </param> /// </param>
/// <exception cref="ArgumentNullException"> /// <exception cref="ArgumentNullException">
@ -1771,9 +1728,9 @@ namespace WebSocketSharp
if (src == null) if (src == null)
throw new ArgumentNullException ("src"); throw new ArgumentNullException ("src");
return src.Length <= 1 || srcOrder.IsHostOrder () return src.Length > 1 && !srcOrder.IsHostOrder ()
? src ? src.Reverse ()
: src.Reverse ().ToArray (); : src;
} }
/// <summary> /// <summary>
@ -1782,8 +1739,8 @@ namespace WebSocketSharp
/// specified <paramref name="separator"/>. /// specified <paramref name="separator"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// A <see cref="string"/> converted from <paramref name="array"/>, or /// A <see cref="string"/> converted from <paramref name="array"/>,
/// <see cref="String.Empty"/> if it's empty. /// or <see cref="String.Empty"/> 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.
@ -1810,8 +1767,7 @@ namespace WebSocketSharp
separator = String.Empty; separator = String.Empty;
var buffer = new StringBuilder (64); var buffer = new StringBuilder (64);
(len - 1).Times ( (len - 1).Times (i => buffer.AppendFormat ("{0}{1}", array [i].ToString (), separator));
i => buffer.AppendFormat ("{0}{1}", array [i].ToString (), separator));
buffer.Append (array [len - 1].ToString ()); buffer.Append (array [len - 1].ToString ());
return buffer.ToString (); return buffer.ToString ();
@ -1821,8 +1777,8 @@ namespace WebSocketSharp
/// Converts the specified <see cref="string"/> to a <see cref="Uri"/>. /// Converts the specified <see cref="string"/> to a <see cref="Uri"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// A <see cref="Uri"/> converted from <paramref name="uriString"/>, or /// A <see cref="Uri"/> converted from <paramref name="uriString"/>, or <see langword="null"/>
/// <see langword="null"/> if it's <see langword="null"/> or empty. /// if <paramref name="uriString"/> is <see langword="null"/> or empty.
/// </returns> /// </returns>
/// <param name="uriString"> /// <param name="uriString">
/// A <see cref="string"/> to convert. /// A <see cref="string"/> to convert.
@ -1840,8 +1796,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 the decoded string, or the /// A <see cref="string"/> that receives the decoded string, or the <paramref name="value"/>
/// <paramref name="value"/> if it's <see langword="null"/> or empty. /// if it's <see langword="null"/> or empty.
/// </returns> /// </returns>
/// <param name="value"> /// <param name="value">
/// A <see cref="string"/> to decode. /// A <see cref="string"/> to decode.
@ -1857,8 +1813,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 the encoded string, or /// A <see cref="string"/> that receives the encoded string, or <paramref name="value"/>
/// <paramref name="value"/> if it's <see langword="null"/> or empty. /// if it's <see langword="null"/> or empty.
/// </returns> /// </returns>
/// <param name="value"> /// <param name="value">
/// A <see cref="string"/> to encode. /// A <see cref="string"/> to encode.
@ -1871,7 +1827,7 @@ namespace WebSocketSharp
} }
/// <summary> /// <summary>
/// Writes the specified <paramref name="content"/> data using the specified /// Writes the specified <paramref name="content"/> data with the specified
/// <see cref="HttpListenerResponse"/>. /// <see cref="HttpListenerResponse"/>.
/// </summary> /// </summary>
/// <param name="response"> /// <param name="response">
@ -1879,13 +1835,12 @@ namespace WebSocketSharp
/// used to write the content data. /// used to write the content data.
/// </param> /// </param>
/// <param name="content"> /// <param name="content">
/// An array of <see cref="byte"/> that contains the content data to write. /// An array of <see cref="byte"/> that represents the content data to write.
/// </param> /// </param>
/// <exception cref="ArgumentNullException"> /// <exception cref="ArgumentNullException">
/// <paramref name="response"/> is <see langword="null"/>. /// <paramref name="response"/> is <see langword="null"/>.
/// </exception> /// </exception>
public static void WriteContent ( public static void WriteContent (this HttpListenerResponse response, byte [] content)
this HttpListenerResponse response, byte [] content)
{ {
if (response == null) if (response == null)
throw new ArgumentNullException ("response"); throw new ArgumentNullException ("response");