Fix due to the modified Ext.cs

This commit is contained in:
sta 2013-05-09 00:41:02 +09:00
parent 8ba6ff1f09
commit 876a017ff0
17 changed files with 71 additions and 68 deletions

Binary file not shown.

View File

@ -13,7 +13,7 @@ namespace Example2 {
private string getName()
{
return QueryString.Exists("name")
return QueryString.Contains("name")
? QueryString["name"]
: "anon#" + getNum();
}

View File

@ -9,7 +9,7 @@ namespace Example2 {
{
protected override void OnMessage(MessageEventArgs e)
{
var msg = QueryString.Exists("name")
var msg = QueryString.Contains("name")
? String.Format("'{0}' returns to {1}", e.Data, QueryString["name"])
: e.Data;
Send(msg);

View File

@ -13,7 +13,7 @@ namespace Example3 {
private string getName()
{
return QueryString.Exists("name")
return QueryString.Contains("name")
? QueryString["name"]
: "anon#" + getNum();
}

View File

@ -8,7 +8,7 @@ namespace Example3 {
{
protected override void OnMessage(MessageEventArgs e)
{
var msg = QueryString.Exists("name")
var msg = QueryString.Contains("name")
? String.Format("'{0}' returns to {1}", e.Data, QueryString["name"])
: e.Data;
Send(msg);

View File

@ -479,6 +479,60 @@ namespace WebSocketSharp {
: value.IndexOfAny(chars) != -1;
}
/// <summary>
/// Determines whether the specified <see cref="NameValueCollection"/> contains the entry
/// with the specified <paramref name="name"/>.
/// </summary>
/// <returns>
/// <c>true</c> if <paramref name="collection"/> contains the entry with <paramref name="name"/>;
/// otherwise, <c>false</c>.
/// </returns>
/// <param name="collection">
/// A <see cref="NameValueCollection"/> that contains the entries.
/// </param>
/// <param name="name">
/// A <see cref="string"/> that contains the key of the entry to find.
/// </param>
public static bool Contains(this NameValueCollection collection, string name)
{
return collection == null
? false
: collection[name] != null;
}
/// <summary>
/// Determines whether the specified <see cref="NameValueCollection"/> contains the entry
/// with the specified both <paramref name="name"/> and <paramref name="value"/>.
/// </summary>
/// <returns>
/// <c>true</c> if <paramref name="collection"/> contains the entry with both <paramref name="name"/> and <paramref name="value"/>;
/// otherwise, <c>false</c>.
/// </returns>
/// <param name="collection">
/// A <see cref="NameValueCollection"/> that contains the entries.
/// </param>
/// <param name="name">
/// A <see cref="string"/> that contains the key of the entry to find.
/// </param>
/// <param name="value">
/// A <see cref="string"/> that contains the value of the entry to find.
/// </param>
public static bool Contains(this NameValueCollection collection, string name, string value)
{
if (collection == null)
return false;
var values = collection[name];
if (values == null)
return false;
foreach (string v in values.Split(','))
if (v.Trim().Equals(value, StringComparison.OrdinalIgnoreCase))
return true;
return false;
}
/// <summary>
/// Emit the specified <see cref="EventHandler"/> delegate if is not <see langword="null"/>.
/// </summary>
@ -551,56 +605,6 @@ namespace WebSocketSharp {
return b == Convert.ToByte(c);
}
/// <summary>
/// Determines whether the entry with the specified key exists in the specified <see cref="NameValueCollection"/>.
/// </summary>
/// <returns>
/// <c>true</c> if the entry with the <paramref name="name"/> exists in the <paramref name="collection"/>; otherwise, <c>false</c>.
/// </returns>
/// <param name="collection">
/// A <see cref="NameValueCollection"/> that contains the entries.
/// </param>
/// <param name="name">
/// A <see cref="string"/> that contains the key of the entry to find.
/// </param>
public static bool Exists(this NameValueCollection collection, string name)
{
return collection == null
? false
: collection[name] != null;
}
/// <summary>
/// Determines whether the entry with the specified both key and value exists in the specified <see cref="NameValueCollection"/>.
/// </summary>
/// <returns>
/// <c>true</c> if the entry with the both <paramref name="name"/> and <paramref name="value"/> exists in the <paramref name="collection"/>; otherwise, <c>false</c>.
/// </returns>
/// <param name="collection">
/// A <see cref="NameValueCollection"/> that contains the entries.
/// </param>
/// <param name="name">
/// A <see cref="string"/> that contains the key of the entry to find.
/// </param>
/// <param name="value">
/// A <see cref="string"/> that contains the value of the entry to find.
/// </param>
public static bool Exists(this NameValueCollection collection, string name, string value)
{
if (collection == null)
return false;
var values = collection[name];
if (values == null)
return false;
foreach (string v in values.Split(','))
if (String.Compare(v.Trim(), value, true) == 0)
return true;
return false;
}
/// <summary>
/// Gets the absolute path from the specified <see cref="Uri"/>.
/// </summary>
@ -645,10 +649,9 @@ namespace WebSocketSharp {
public static CookieCollection GetCookies(this NameValueCollection headers, bool response)
{
var name = response ? "Set-Cookie" : "Cookie";
if (headers == null || !headers.Exists(name))
return new CookieCollection();
return CookieCollection.Parse(headers[name], response);
return headers == null || !headers.Contains(name)
? new CookieCollection()
: CookieCollection.Parse(headers[name], response);
}
/// <summary>
@ -999,10 +1002,10 @@ namespace WebSocketSharp {
if (protocol.Length == 0)
throw new ArgumentException("Must not be empty.", "protocol");
if (!request.Headers.Exists("Upgrade", protocol))
if (!request.Headers.Contains("Upgrade", protocol))
return false;
if (!request.Headers.Exists("Connection", "Upgrade"))
if (!request.Headers.Contains("Connection", "Upgrade"))
return false;
return true;

View File

@ -72,12 +72,12 @@ namespace WebSocketSharp {
public bool ContainsHeader(string name)
{
return Headers.Exists(name);
return Headers.Contains(name);
}
public bool ContainsHeader(string name, string value)
{
return Headers.Exists(name, value);
return Headers.Contains(name, value);
}
public string[] GetHeaderValues(string name)

View File

@ -265,15 +265,15 @@ namespace WebSocketSharp.Net {
? false
: version < HttpVersion.Version11
? false
: !headers.Exists("Upgrade", "websocket")
: !headers.Contains("Upgrade", "websocket")
? false
: !headers.Exists("Connection", "Upgrade")
: !headers.Contains("Connection", "Upgrade")
? false
: !headers.Exists("Host")
: !headers.Contains("Host")
? false
: !headers.Exists("Sec-WebSocket-Key")
: !headers.Contains("Sec-WebSocket-Key")
? false
: headers.Exists("Sec-WebSocket-Version");
: headers.Contains("Sec-WebSocket-Version");
}
}

View File

@ -819,7 +819,7 @@ namespace WebSocketSharp {
? false
: !isValidHostHeader()
? false
: _context.Headers.Exists("Sec-WebSocket-Version", _version);
: _context.Headers.Contains("Sec-WebSocket-Version", _version);
}
// As client