Browse Source

Refactored HttpListenerPrefixCollection.cs

pull/83/merge
sta 11 years ago
parent
commit
4cfdd7e793
  1. 9
      websocket-sharp/Net/HttpListenerPrefixCollection.cs

9
websocket-sharp/Net/HttpListenerPrefixCollection.cs

@ -139,8 +139,9 @@ namespace WebSocketSharp.Net
/// </exception> /// </exception>
public void Add (string uriPrefix) public void Add (string uriPrefix)
{ {
_listener.CheckDisposed ();
ListenerPrefix.CheckUriPrefix (uriPrefix); ListenerPrefix.CheckUriPrefix (uriPrefix);
_listener.CheckDisposed ();
if (_prefixes.Contains (uriPrefix)) if (_prefixes.Contains (uriPrefix))
return; return;
@ -158,6 +159,7 @@ namespace WebSocketSharp.Net
public void Clear () public void Clear ()
{ {
_listener.CheckDisposed (); _listener.CheckDisposed ();
_prefixes.Clear (); _prefixes.Clear ();
if (_listener.IsListening) if (_listener.IsListening)
EndPointManager.RemoveListener (_listener); EndPointManager.RemoveListener (_listener);
@ -182,10 +184,10 @@ namespace WebSocketSharp.Net
/// </exception> /// </exception>
public bool Contains (string uriPrefix) public bool Contains (string uriPrefix)
{ {
_listener.CheckDisposed ();
if (uriPrefix == null) if (uriPrefix == null)
throw new ArgumentNullException ("uriPrefix"); throw new ArgumentNullException ("uriPrefix");
_listener.CheckDisposed ();
return _prefixes.Contains (uriPrefix); return _prefixes.Contains (uriPrefix);
} }
@ -257,10 +259,11 @@ namespace WebSocketSharp.Net
/// </exception> /// </exception>
public bool Remove (string uriPrefix) public bool Remove (string uriPrefix)
{ {
_listener.CheckDisposed ();
if (uriPrefix == null) if (uriPrefix == null)
throw new ArgumentNullException ("uriPrefix"); throw new ArgumentNullException ("uriPrefix");
_listener.CheckDisposed ();
var res = _prefixes.Remove (uriPrefix); var res = _prefixes.Remove (uriPrefix);
if (res && _listener.IsListening) if (res && _listener.IsListening)
EndPointManager.RemovePrefix (uriPrefix, _listener); EndPointManager.RemovePrefix (uriPrefix, _listener);

Loading…
Cancel
Save