From 4cfdd7e79364f8d0a4689fb0fd33b69d39a3d46d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Oct 2014 14:42:08 +0900 Subject: [PATCH] Refactored HttpListenerPrefixCollection.cs --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 36ced9ea..15d79b66 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -139,8 +139,9 @@ namespace WebSocketSharp.Net /// public void Add (string uriPrefix) { - _listener.CheckDisposed (); ListenerPrefix.CheckUriPrefix (uriPrefix); + _listener.CheckDisposed (); + if (_prefixes.Contains (uriPrefix)) return; @@ -158,6 +159,7 @@ namespace WebSocketSharp.Net public void Clear () { _listener.CheckDisposed (); + _prefixes.Clear (); if (_listener.IsListening) EndPointManager.RemoveListener (_listener); @@ -182,10 +184,10 @@ namespace WebSocketSharp.Net /// public bool Contains (string uriPrefix) { - _listener.CheckDisposed (); if (uriPrefix == null) throw new ArgumentNullException ("uriPrefix"); + _listener.CheckDisposed (); return _prefixes.Contains (uriPrefix); } @@ -257,10 +259,11 @@ namespace WebSocketSharp.Net /// public bool Remove (string uriPrefix) { - _listener.CheckDisposed (); if (uriPrefix == null) throw new ArgumentNullException ("uriPrefix"); + _listener.CheckDisposed (); + var res = _prefixes.Remove (uriPrefix); if (res && _listener.IsListening) EndPointManager.RemovePrefix (uriPrefix, _listener);