Browse Source

refactor and remove files.

master
Savorboard 7 years ago
parent
commit
7766d408c4
3 changed files with 0 additions and 79 deletions
  1. +0
    -14
      src/DotNetCore.CAP/Dashboard/GatewayProxy/HostAndPort.cs
  2. +0
    -56
      src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestScopedDataRepository.HttpData.cs
  3. +0
    -9
      src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestScopedDataRepository.cs

+ 0
- 14
src/DotNetCore.CAP/Dashboard/GatewayProxy/HostAndPort.cs View File

@@ -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; }
}
}

+ 0
- 56
src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestScopedDataRepository.HttpData.cs View File

@@ -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<T>(string key, T value)
{
_httpContextAccessor.HttpContext.Items.Add(key, value);
}

public T Get<T>(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<string, object> dictionary = null;

public ScopedDataRepository()
{
dictionary = new ConcurrentDictionary<string, object>();
}

public void Add<T>(string key, T value)
{
dictionary.AddOrUpdate(key, value, (k, v) => value);
}

public T Get<T>(string key)
{
if (dictionary.TryGetValue(key, out object t))
{
return (T)t;
}
throw new Exception($"Unable to find data for key: {key}");
}
}
}

+ 0
- 9
src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestScopedDataRepository.cs View File

@@ -1,9 +0,0 @@
namespace DotNetCore.CAP.Dashboard.GatewayProxy
{
public interface IRequestScopedDataRepository
{
void Add<T>(string key, T value);

T Get<T>(string key);
}
}

Loading…
Cancel
Save