@ -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"/> t hat contains the entries .
/// A <see cref="NameValueCollection"/> t o 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"/> t hat contains the entries .
/// A <see cref="NameValueCollection"/> t o 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"/>.
/// Emit s the specified <see cref="EventHandler"/> delegate if not <see langword="null"/>.
/// </summary>
/// </summary>
/// <param name="eventHandler">
/// <param name="eventHandler">
/// A n <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">
/// A n <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"/>.
/// Emit s 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 contain s an HTTP status code.
/// One of <see cref=" HttpStatusCode"/> values that indicate s 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"/> wa s successfully created; otherwise, <c>false</c>.
/// <c>true</c> if a WebSocket <see cref="Uri"/> i s 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 )
{
{