Refactored a few for HttpListener.cs

This commit is contained in:
sta 2015-05-15 17:47:32 +09:00
parent 9efcbbe960
commit ff06963613

View File

@ -315,9 +315,7 @@ namespace WebSocketSharp.Net
public string Realm { public string Realm {
get { get {
CheckDisposed (); CheckDisposed ();
return _realm != null && _realm.Length > 0 return _realm != null && _realm.Length > 0 ? _realm : (_realm = "SECRET AREA");
? _realm
: (_realm = "SECRET AREA");
} }
set { set {
@ -331,8 +329,8 @@ namespace WebSocketSharp.Net
/// optionally the client for secure connection. /// optionally the client for secure connection.
/// </summary> /// </summary>
/// <value> /// <value>
/// A <see cref="ServerSslConfiguration"/> that represents the configuration used /// A <see cref="ServerSslConfiguration"/> that represents the configuration used to
/// to authenticate the server and optionally the client for secure connection. /// authenticate the server and optionally the client for secure connection.
/// </value> /// </value>
/// <exception cref="ObjectDisposedException"> /// <exception cref="ObjectDisposedException">
/// This listener has been closed. /// This listener has been closed.
@ -380,9 +378,9 @@ namespace WebSocketSharp.Net
/// authenticate a client. /// authenticate a client.
/// </summary> /// </summary>
/// <value> /// <value>
/// A <c>Func&lt;<see cref="IIdentity"/>, <see cref="NetworkCredential"/>&gt;</c> delegate /// A <c>Func&lt;<see cref="IIdentity"/>, <see cref="NetworkCredential"/>&gt;</c> delegate that
/// that references the method used to find the credentials. The default value is a function /// references the method used to find the credentials. The default value is a function that
/// that only returns <see langword="null"/>. /// only returns <see langword="null"/>.
/// </value> /// </value>
/// <exception cref="ObjectDisposedException"> /// <exception cref="ObjectDisposedException">
/// This listener has been closed. /// This listener has been closed.
@ -421,7 +419,7 @@ namespace WebSocketSharp.Net
if (_connections.Count == 0) if (_connections.Count == 0)
return; return;
// Need to copy this since closing will call RemoveConnection. // Need to copy this since closing will call the RemoveConnection method.
var keys = _connections.Keys; var keys = _connections.Keys;
var conns = new HttpConnection[keys.Count]; var conns = new HttpConnection[keys.Count];
keys.CopyTo (conns, 0); keys.CopyTo (conns, 0);
@ -437,7 +435,7 @@ namespace WebSocketSharp.Net
if (_ctxRegistry.Count == 0) if (_ctxRegistry.Count == 0)
return; return;
// Need to copy this since closing will call UnregisterContext. // Need to copy this since closing will call the UnregisterContext method.
var keys = _ctxRegistry.Keys; var keys = _ctxRegistry.Keys;
var ctxs = new HttpListenerContext[keys.Count]; var ctxs = new HttpListenerContext[keys.Count];
keys.CopyTo (ctxs, 0); keys.CopyTo (ctxs, 0);
@ -608,9 +606,9 @@ namespace WebSocketSharp.Net
_ctxRegistry.Remove (context); _ctxRegistry.Remove (context);
lock (_ctxQueueSync) { lock (_ctxQueueSync) {
var i = _ctxQueue.IndexOf (context); var idx = _ctxQueue.IndexOf (context);
if (i >= 0) if (idx >= 0)
_ctxQueue.RemoveAt (i); _ctxQueue.RemoveAt (idx);
} }
} }
@ -641,8 +639,8 @@ namespace WebSocketSharp.Net
/// An <see cref="IAsyncResult"/> that represents the status of the asynchronous operation. /// An <see cref="IAsyncResult"/> that represents the status of the asynchronous operation.
/// </returns> /// </returns>
/// <param name="callback"> /// <param name="callback">
/// An <see cref="AsyncCallback"/> delegate that references the method to invoke /// An <see cref="AsyncCallback"/> delegate that references the method to invoke when
/// when the asynchronous operation completes. /// the asynchronous operation completes.
/// </param> /// </param>
/// <param name="state"> /// <param name="state">
/// An <see cref="object"/> that represents a user defined object to pass to /// An <see cref="object"/> that represents a user defined object to pass to
@ -721,7 +719,7 @@ namespace WebSocketSharp.Net
if (!ares.IsCompleted) if (!ares.IsCompleted)
ares.AsyncWaitHandle.WaitOne (); ares.AsyncWaitHandle.WaitOne ();
return ares.GetContext (); // This will throw on error. return ares.GetContext (); // This may throw an exception.
} }
/// <summary> /// <summary>