Class Ext
Provides a set of static methods for websocket-sharp.
Inheritance
System.Object
Ext
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Mars.Common.dll
Syntax
Methods
|
Improve this Doc
View Source
Contains(NameValueCollection, String, String)
Determines whether the specified System.Collections.Specialized.NameValueCollection contains the entry with
the specified both name and value.
Declaration
public static bool Contains(this NameValueCollection collection, string name, string value)
Parameters
| Type |
Name |
Description |
| System.Collections.Specialized.NameValueCollection |
collection |
A System.Collections.Specialized.NameValueCollection to test.
|
| System.String |
name |
A System.String that represents the key of the entry to find.
|
| System.String |
value |
A System.String that represents the value of the entry to find.
|
Returns
| Type |
Description |
| System.Boolean |
true if collection contains the entry with both
name and value; otherwise, false.
|
|
Improve this Doc
View Source
Contains(NameValueCollection, String)
Determines whether the specified System.Collections.Specialized.NameValueCollection contains
the entry with the specified name.
Declaration
public static bool Contains(this NameValueCollection collection, string name)
Parameters
| Type |
Name |
Description |
| System.Collections.Specialized.NameValueCollection |
collection |
A System.Collections.Specialized.NameValueCollection to test.
|
| System.String |
name |
A System.String that represents the key of the entry to find.
|
Returns
| Type |
Description |
| System.Boolean |
true if collection contains the entry with
name; otherwise, false.
|
|
Improve this Doc
View Source
Contains(String, Char[])
Determines whether the specified System.String contains any of characters in
the specified array of System.Char.
Declaration
public static bool Contains(this string value, params char[] chars)
Parameters
| Type |
Name |
Description |
| System.String |
value |
A System.String to test.
|
| System.Char[] |
chars |
An array of System.Char that contains characters to find.
|
Returns
| Type |
Description |
| System.Boolean |
true if value contains any of chars;
otherwise, false.
|
|
Improve this Doc
View Source
Emit(EventHandler, Object, EventArgs)
Emits the specified System.EventHandler delegate if it isn't null.
Declaration
public static void Emit(this EventHandler eventHandler, object sender, EventArgs e)
Parameters
| Type |
Name |
Description |
| System.EventHandler |
eventHandler |
A System.EventHandler to emit.
|
| System.Object |
sender |
An System.Object from which emits this eventHandler.
|
| System.EventArgs |
e |
A System.EventArgs that contains no event data.
|
|
Improve this Doc
View Source
Emit<TEventArgs>(EventHandler<TEventArgs>, Object, TEventArgs)
Emits the specified EventHandler<TEventArgs> delegate if it isn't
null.
Declaration
public static void Emit<TEventArgs>(this EventHandler<TEventArgs> eventHandler, object sender, TEventArgs e)
where TEventArgs : EventArgs
Parameters
| Type |
Name |
Description |
| System.EventHandler<TEventArgs> |
eventHandler |
An EventHandler<TEventArgs> to emit.
|
| System.Object |
sender |
An System.Object from which emits this eventHandler.
|
| TEventArgs |
e |
A TEventArgs that represents the event data.
|
Type Parameters
| Name |
Description |
| TEventArgs |
The type of the event data generated by the event.
|
|
Improve this Doc
View Source
GetDescription(HttpStatusCode)
Gets the description of the specified HTTP status code.
Declaration
public static string GetDescription(this HttpStatusCode code)
Parameters
| Type |
Name |
Description |
| System.Net.HttpStatusCode |
code |
One of System.Net.HttpStatusCode enum values, indicates the HTTP status code.
|
Returns
| Type |
Description |
| System.String |
A System.String that represents the description of the HTTP status code.
|
|
Improve this Doc
View Source
GetStatusDescription(Int32)
Gets the description of the specified HTTP status code.
Declaration
public static string GetStatusDescription(this int code)
Parameters
| Type |
Name |
Description |
| System.Int32 |
code |
An System.Int32 that represents the HTTP status code.
|
Returns
| Type |
Description |
| System.String |
A System.String that represents the description of the HTTP status code.
|
|
Improve this Doc
View Source
IsCloseStatusCode(UInt16)
Determines whether the specified System.UInt16 is in the
range of the status code for the WebSocket connection close.
Declaration
public static bool IsCloseStatusCode(this ushort value)
Parameters
| Type |
Name |
Description |
| System.UInt16 |
value |
A System.UInt16 to test.
|
Returns
| Type |
Description |
| System.Boolean |
true if value is in the range of
the status code for the close; otherwise, false.
|
|
Improve this Doc
View Source
IsEnclosedIn(String, Char)
Determines whether the specified System.String is
enclosed in the specified System.Char.
Declaration
public static bool IsEnclosedIn(this string value, char c)
Parameters
| Type |
Name |
Description |
| System.String |
value |
A System.String to test.
|
| System.Char |
c |
A System.Char to find.
|
Returns
| Type |
Description |
| System.Boolean |
true if value is enclosed in
c; otherwise, false.
|
|
Improve this Doc
View Source
IsHostOrder(ByteOrder)
Determines whether the specified
ByteOrder is host (this computer
architecture) byte order.
Declaration
public static bool IsHostOrder(this ByteOrder order)
Parameters
Returns
| Type |
Description |
| System.Boolean |
true if order is host byte order; otherwise, false.
|
|
Improve this Doc
View Source
IsLocal(IPAddress)
Determines whether the specified System.Net.IPAddress
represents a local IP address.
Declaration
public static bool IsLocal(this IPAddress address)
Parameters
| Type |
Name |
Description |
| System.Net.IPAddress |
address |
A System.Net.IPAddress to test.
|
Returns
| Type |
Description |
| System.Boolean |
true if address represents a local IP address;
otherwise, false.
|
|
Improve this Doc
View Source
IsNullOrEmpty(String)
Determines whether the specified string is null or
an empty string.
Declaration
public static bool IsNullOrEmpty(this string value)
Parameters
| Type |
Name |
Description |
| System.String |
value |
A System.String to test.
|
Returns
| Type |
Description |
| System.Boolean |
true if the string is null or an empty string;
otherwise, false.
|
|
Improve this Doc
View Source
IsPredefinedScheme(String)
Determines whether the specified System.String is
a predefined scheme.
Declaration
public static bool IsPredefinedScheme(this string value)
Parameters
| Type |
Name |
Description |
| System.String |
value |
A System.String to test.
|
Returns
| Type |
Description |
| System.Boolean |
true if value is a predefined scheme;
otherwise, false.
|
|
Improve this Doc
View Source
IsUpgradeTo(HttpListenerRequest, String)
Determines whether the specified System.Net.HttpListenerRequest is
an HTTP Upgrade request to switch to the specified protocol.
Declaration
public static bool IsUpgradeTo(this HttpListenerRequest request, string protocol)
Parameters
| Type |
Name |
Description |
| System.Net.HttpListenerRequest |
request |
A System.Net.HttpListenerRequest that represents the HTTP request.
|
| System.String |
protocol |
A System.String that represents the protocol name.
|
Returns
| Type |
Description |
| System.Boolean |
true if request is an HTTP Upgrade request to switch to
protocol; otherwise, false.
|
Exceptions
| Type |
Condition |
| System.ArgumentNullException |
request is null.
-or-
protocol is null.
|
| System.ArgumentException |
protocol is empty.
|
|
Improve this Doc
View Source
MaybeUri(String)
Determines whether the specified System.String is a URI string.
Declaration
public static bool MaybeUri(this string value)
Parameters
| Type |
Name |
Description |
| System.String |
value |
A System.String to test.
|
Returns
| Type |
Description |
| System.Boolean |
true if value may be a URI string;
otherwise, false.
|
|
Improve this Doc
View Source
SubArray<T>(T[], Int32, Int32)
Retrieves a sub-array from the specified array. A sub-array starts at
the specified element position in array.
Declaration
public static T[] SubArray<T>(this T[] array, int startIndex, int length)
Parameters
| Type |
Name |
Description |
| T[] |
array |
An array of T from which to retrieve a sub-array.
|
| System.Int32 |
startIndex |
An System.Int32 that represents the zero-based starting position of
a sub-array in array.
|
| System.Int32 |
length |
An System.Int32 that represents the number of elements to retrieve.
|
Returns
| Type |
Description |
| T[] |
An array of T that receives a sub-array, or an empty array of T if any problems with
the parameters.
|
Type Parameters
| Name |
Description |
| T |
The type of elements in array.
|
|
Improve this Doc
View Source
SubArray<T>(T[], Int64, Int64)
Retrieves a sub-array from the specified array. A sub-array starts at
the specified element position in array.
Declaration
public static T[] SubArray<T>(this T[] array, long startIndex, long length)
Parameters
| Type |
Name |
Description |
| T[] |
array |
An array of T from which to retrieve a sub-array.
|
| System.Int64 |
startIndex |
A System.Int64 that represents the zero-based starting position of
a sub-array in array.
|
| System.Int64 |
length |
A System.Int64 that represents the number of elements to retrieve.
|
Returns
| Type |
Description |
| T[] |
An array of T that receives a sub-array, or an empty array of T if any problems with
the parameters.
|
Type Parameters
| Name |
Description |
| T |
The type of elements in array.
|
|
Improve this Doc
View Source
Times(Int32, Action)
Executes the specified System.Action delegate n times.
Declaration
public static void Times(this int n, Action action)
Parameters
| Type |
Name |
Description |
| System.Int32 |
n |
An System.Int32 is the number of times to execute.
|
| System.Action |
action |
An System.Action delegate that references the method(s) to execute.
|
|
Improve this Doc
View Source
Times(Int32, Action<Int32>)
Executes the specified Action<int> delegate n times.
Declaration
public static void Times(this int n, Action<int> action)
Parameters
| Type |
Name |
Description |
| System.Int32 |
n |
An System.Int32 is the number of times to execute.
|
| System.Action<System.Int32> |
action |
An Action<int> delegate that references the method(s) to execute.
An System.Int32 parameter to pass to the method(s) is the zero-based count of
iteration.
|
|
Improve this Doc
View Source
Times(Int64, Action)
Executes the specified System.Action delegate n times.
Declaration
public static void Times(this long n, Action action)
Parameters
| Type |
Name |
Description |
| System.Int64 |
n |
A System.Int64 is the number of times to execute.
|
| System.Action |
action |
An System.Action delegate that references the method(s) to execute.
|
|
Improve this Doc
View Source
Times(Int64, Action<Int64>)
Executes the specified Action<long> delegate n times.
Declaration
public static void Times(this long n, Action<long> action)
Parameters
| Type |
Name |
Description |
| System.Int64 |
n |
A System.Int64 is the number of times to execute.
|
| System.Action<System.Int64> |
action |
An Action<long> delegate that references the method(s) to execute.
A System.Int64 parameter to pass to the method(s) is the zero-based count of
iteration.
|
|
Improve this Doc
View Source
Times(UInt32, Action)
Executes the specified System.Action delegate n times.
Declaration
public static void Times(this uint n, Action action)
Parameters
| Type |
Name |
Description |
| System.UInt32 |
n |
A System.UInt32 is the number of times to execute.
|
| System.Action |
action |
An System.Action delegate that references the method(s) to execute.
|
|
Improve this Doc
View Source
Times(UInt32, Action<UInt32>)
Executes the specified Action<uint> delegate n times.
Declaration
public static void Times(this uint n, Action<uint> action)
Parameters
| Type |
Name |
Description |
| System.UInt32 |
n |
A System.UInt32 is the number of times to execute.
|
| System.Action<System.UInt32> |
action |
An Action<uint> delegate that references the method(s) to execute.
A System.UInt32 parameter to pass to the method(s) is the zero-based count of
iteration.
|
|
Improve this Doc
View Source
Times(UInt64, Action)
Executes the specified System.Action delegate n times.
Declaration
public static void Times(this ulong n, Action action)
Parameters
| Type |
Name |
Description |
| System.UInt64 |
n |
A System.UInt64 is the number of times to execute.
|
| System.Action |
action |
An System.Action delegate that references the method(s) to execute.
|
|
Improve this Doc
View Source
Times(UInt64, Action<UInt64>)
Executes the specified Action<ulong> delegate n times.
Declaration
public static void Times(this ulong n, Action<ulong> action)
Parameters
| Type |
Name |
Description |
| System.UInt64 |
n |
A System.UInt64 is the number of times to execute.
|
| System.Action<System.UInt64> |
action |
An Action<ulong> delegate that references the method(s) to execute.
A System.UInt64 parameter to pass to this method(s) is the zero-based count of
iteration.
|
|
Improve this Doc
View Source
To<T>(Byte[], ByteOrder)
Converts the specified array of System.Byte to the specified type data.
Declaration
public static T To<T>(this byte[] source, ByteOrder sourceOrder)
where T : struct
Parameters
| Type |
Name |
Description |
| System.Byte[] |
source |
An array of System.Byte to convert.
|
| ByteOrder |
sourceOrder |
One of the ByteOrder enum values, specifies the byte order of
source.
|
Returns
| Type |
Description |
| T |
A T converted from source, or a default value of
T if source is an empty array of System.Byte or
if the type of T isn't System.Boolean, System.Char, System.Double,
System.Single, System.Int32, System.Int64, System.Int16,
System.UInt32, System.UInt64, or System.UInt16.
|
Type Parameters
| Name |
Description |
| T |
The type of the return. The T must be a value type.
|
Exceptions
| Type |
Condition |
| System.ArgumentNullException |
source is null.
|
|
Improve this Doc
View Source
ToByteArray<T>(T, ByteOrder)
Converts the specified value to an array of System.Byte.
Declaration
public static byte[] ToByteArray<T>(this T value, ByteOrder order)
where T : struct
Parameters
| Type |
Name |
Description |
| T |
value |
A T to convert.
|
| ByteOrder |
order |
One of the ByteOrder enum values, specifies the byte order of the return.
|
Returns
| Type |
Description |
| System.Byte[] |
An array of System.Byte converted from value.
|
Type Parameters
| Name |
Description |
| T |
The type of value. The T must be a value type.
|
|
Improve this Doc
View Source
ToHostOrder(Byte[], ByteOrder)
Converts the order of the specified array of System.Byte to the host byte order.
Declaration
public static byte[] ToHostOrder(this byte[] source, ByteOrder sourceOrder)
Parameters
| Type |
Name |
Description |
| System.Byte[] |
source |
An array of System.Byte to convert.
|
| ByteOrder |
sourceOrder |
One of the ByteOrder enum values, specifies the byte order of
source.
|
Returns
| Type |
Description |
| System.Byte[] |
An array of System.Byte converted from source.
|
Exceptions
| Type |
Condition |
| System.ArgumentNullException |
source is null.
|
|
Improve this Doc
View Source
ToString<T>(T[], String)
Converts the specified array to a System.String that
concatenates the each element of array across the specified
separator.
Declaration
public static string ToString<T>(this T[] array, string separator)
Parameters
| Type |
Name |
Description |
| T[] |
array |
An array of T to convert.
|
| System.String |
separator |
A System.String that represents the separator string.
|
Returns
| Type |
Description |
| System.String |
A System.String converted from array,
or System.String.Empty if array is empty.
|
Type Parameters
| Name |
Description |
| T |
The type of elements in array.
|
Exceptions
| Type |
Condition |
| System.ArgumentNullException |
array is null.
|
|
Improve this Doc
View Source
ToUri(String)
Converts the specified System.String to a System.Uri.
Declaration
public static Uri ToUri(this string value)
Parameters
| Type |
Name |
Description |
| System.String |
value |
A System.String to convert.
|
Returns
| Type |
Description |
| System.Uri |
A System.Uri converted from value or
null if the convert has failed.
|
|
Improve this Doc
View Source
UrlDecode(String)
URL-decodes the specified System.String.
Declaration
public static string UrlDecode(this string value)
Parameters
| Type |
Name |
Description |
| System.String |
value |
A System.String to decode.
|
Returns
| Type |
Description |
| System.String |
A System.String that receives the decoded string or
value if it is null or empty.
|
|
Improve this Doc
View Source
UrlEncode(String)
URL-encodes the specified System.String.
Declaration
public static string UrlEncode(this string value)
Parameters
| Type |
Name |
Description |
| System.String |
value |
A System.String to encode.
|
Returns
| Type |
Description |
| System.String |
A System.String that receives the encoded string or
value if it is null or empty.
|
|
Improve this Doc
View Source
WriteContent(HttpListenerResponse, Byte[])
Writes and sends the specified content data with the specified
System.Net.HttpListenerResponse.
Declaration
public static void WriteContent(this HttpListenerResponse response, byte[] content)
Parameters
| Type |
Name |
Description |
| System.Net.HttpListenerResponse |
response |
A System.Net.HttpListenerResponse that represents the HTTP response used to
send the content data.
|
| System.Byte[] |
content |
An array of System.Byte that represents the content data to send.
|
Exceptions
| Type |
Condition |
| System.ArgumentNullException |
response is null.
-or-
content is null.
|