aboutsummaryrefslogtreecommitdiff
path: root/SocketHttpListener/Net/HttpListenerPrefixCollection.cs
diff options
context:
space:
mode:
authorClaus Vium <clausvium@gmail.com>2019-02-21 10:07:21 +0100
committerClaus Vium <clausvium@gmail.com>2019-02-26 22:11:21 +0100
commit4db31acff940dc9cabbd39649103faf4dc2e2c47 (patch)
tree4472b2330124f2bfea3f9dcdfcd5508cedd84570 /SocketHttpListener/Net/HttpListenerPrefixCollection.cs
parent968e282c907f57d7998b6435cadae2f0a5ec832c (diff)
Begin removing System.Net sources
Diffstat (limited to 'SocketHttpListener/Net/HttpListenerPrefixCollection.cs')
-rw-r--r--SocketHttpListener/Net/HttpListenerPrefixCollection.cs117
1 files changed, 0 insertions, 117 deletions
diff --git a/SocketHttpListener/Net/HttpListenerPrefixCollection.cs b/SocketHttpListener/Net/HttpListenerPrefixCollection.cs
deleted file mode 100644
index 400a1adb6..000000000
--- a/SocketHttpListener/Net/HttpListenerPrefixCollection.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using Microsoft.Extensions.Logging;
-
-namespace SocketHttpListener.Net
-{
- public class HttpListenerPrefixCollection : ICollection<string>, IEnumerable<string>, IEnumerable
- {
- private List<string> _prefixes = new List<string>();
- private HttpListener _listener;
-
- private ILogger _logger;
-
- internal HttpListenerPrefixCollection(ILogger logger, HttpListener listener)
- {
- _logger = logger;
- _listener = listener;
- }
-
- public int Count => _prefixes.Count;
-
- public bool IsReadOnly => false;
-
- public bool IsSynchronized => false;
-
- public void Add(string uriPrefix)
- {
- _listener.CheckDisposed();
- //ListenerPrefix.CheckUri(uriPrefix);
- if (_prefixes.Contains(uriPrefix))
- {
- return;
- }
-
- _prefixes.Add(uriPrefix);
- if (_listener.IsListening)
- {
- HttpEndPointManager.AddPrefix(_logger, uriPrefix, _listener);
- }
- }
-
- public void AddRange(IEnumerable<string> uriPrefixes)
- {
- _listener.CheckDisposed();
-
- foreach (var uriPrefix in uriPrefixes)
- {
- if (_prefixes.Contains(uriPrefix))
- {
- continue;
- }
-
- _prefixes.Add(uriPrefix);
- if (_listener.IsListening)
- {
- HttpEndPointManager.AddPrefix(_logger, uriPrefix, _listener);
- }
- }
- }
-
- public void Clear()
- {
- _listener.CheckDisposed();
- _prefixes.Clear();
- if (_listener.IsListening)
- {
- HttpEndPointManager.RemoveListener(_logger, _listener);
- }
- }
-
- public bool Contains(string uriPrefix)
- {
- _listener.CheckDisposed();
- return _prefixes.Contains(uriPrefix);
- }
-
- public void CopyTo(string[] array, int offset)
- {
- _listener.CheckDisposed();
- _prefixes.CopyTo(array, offset);
- }
-
- public void CopyTo(Array array, int offset)
- {
- _listener.CheckDisposed();
- ((ICollection)_prefixes).CopyTo(array, offset);
- }
-
- public IEnumerator<string> GetEnumerator()
- {
- return _prefixes.GetEnumerator();
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return _prefixes.GetEnumerator();
- }
-
- public bool Remove(string uriPrefix)
- {
- _listener.CheckDisposed();
- if (uriPrefix == null)
- {
- throw new ArgumentNullException(nameof(uriPrefix));
- }
-
- bool result = _prefixes.Remove(uriPrefix);
- if (result && _listener.IsListening)
- {
- HttpEndPointManager.RemovePrefix(_logger, uriPrefix, _listener);
- }
-
- return result;
- }
- }
-}