From 7766d408c42169437453a1814538f5287786312d Mon Sep 17 00:00:00 2001 From: Savorboard Date: Tue, 26 Sep 2017 23:17:31 +0800 Subject: [PATCH] refactor and remove files. --- .../Dashboard/GatewayProxy/HostAndPort.cs | 14 ----- .../IRequestScopedDataRepository.HttpData.cs | 56 ------------------- .../IRequestScopedDataRepository.cs | 9 --- 3 files changed, 79 deletions(-) delete mode 100644 src/DotNetCore.CAP/Dashboard/GatewayProxy/HostAndPort.cs delete mode 100644 src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestScopedDataRepository.HttpData.cs delete mode 100644 src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestScopedDataRepository.cs diff --git a/src/DotNetCore.CAP/Dashboard/GatewayProxy/HostAndPort.cs b/src/DotNetCore.CAP/Dashboard/GatewayProxy/HostAndPort.cs deleted file mode 100644 index a42e23b..0000000 --- a/src/DotNetCore.CAP/Dashboard/GatewayProxy/HostAndPort.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace DotNetCore.CAP.Dashboard.GatewayProxy -{ - public class HostAndPort - { - public HostAndPort(string downstreamHost, int downstreamPort) - { - DownstreamHost = downstreamHost?.Trim('/'); - DownstreamPort = downstreamPort; - } - - public string DownstreamHost { get; private set; } - public int DownstreamPort { get; private set; } - } -} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestScopedDataRepository.HttpData.cs b/src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestScopedDataRepository.HttpData.cs deleted file mode 100644 index 6215668..0000000 --- a/src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestScopedDataRepository.HttpData.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Concurrent; -using Microsoft.AspNetCore.Http; - -namespace DotNetCore.CAP.Dashboard.GatewayProxy -{ - public class HttpDataRepository : IRequestScopedDataRepository - { - private readonly IHttpContextAccessor _httpContextAccessor; - - public HttpDataRepository(IHttpContextAccessor httpContextAccessor) - { - _httpContextAccessor = httpContextAccessor; - } - - public void Add(string key, T value) - { - _httpContextAccessor.HttpContext.Items.Add(key, value); - } - - public T Get(string key) - { - object obj; - - if (_httpContextAccessor.HttpContext.Items.TryGetValue(key, out obj)) - { - return (T)obj; - } - throw new Exception($"Unable to find data for key: {key}"); - } - } - - public class ScopedDataRepository : IRequestScopedDataRepository - { - private readonly ConcurrentDictionary dictionary = null; - - public ScopedDataRepository() - { - dictionary = new ConcurrentDictionary(); - } - - public void Add(string key, T value) - { - dictionary.AddOrUpdate(key, value, (k, v) => value); - } - - public T Get(string key) - { - if (dictionary.TryGetValue(key, out object t)) - { - return (T)t; - } - throw new Exception($"Unable to find data for key: {key}"); - } - } -} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestScopedDataRepository.cs b/src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestScopedDataRepository.cs deleted file mode 100644 index 3f8c6d3..0000000 --- a/src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestScopedDataRepository.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace DotNetCore.CAP.Dashboard.GatewayProxy -{ - public interface IRequestScopedDataRepository - { - void Add(string key, T value); - - T Get(string key); - } -} \ No newline at end of file