增加项目,分层
This commit is contained in:
1 parent
6e995a5bdb
commit
0a3e5af6a9
234 files changed
+26994
-1
No files matched your search
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.Configs
|
||||
{
|
||||
/// <summary>
|
||||
/// 全局配置
|
||||
/// </summary>
|
||||
public class GlobalConfig
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// app启动路径
|
||||
/// </summary>
|
||||
public static string AppDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppDomain.CurrentDomain.BaseDirectory;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace Store.Client
|
||||
{
|
||||
public interface IApiServerConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务器地址
|
||||
/// </summary>
|
||||
string Host { get; }
|
||||
/// <summary>
|
||||
/// 项目地址
|
||||
/// </summary>
|
||||
string ObjUrl { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//namespace Store.Client
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// 根据 DI 注册 Key 获取服务配置。
|
||||
// /// Keyed DI 配置作为初始值,登录后获取到的服务地址可以覆盖初始值。
|
||||
// /// </summary>
|
||||
// public interface IServiceConfigProvider
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 获取指定 Key 的服务配置。
|
||||
// /// </summary>
|
||||
// IServerConfig Get(string key);
|
||||
|
||||
// /// <summary>
|
||||
// /// 尝试获取指定 Key 的服务配置。
|
||||
// /// </summary>
|
||||
// bool TryGet(string key, out IServerConfig config);
|
||||
|
||||
// /// <summary>
|
||||
// /// 设置或覆盖指定 Key 的完整服务配置。
|
||||
// /// </summary>
|
||||
// void Set(string key, IServerConfig config);
|
||||
|
||||
// /// <summary>
|
||||
// /// 设置或覆盖指定 Key 的服务配置。
|
||||
// /// </summary>
|
||||
// void Set(string key, string host, string objUrl);
|
||||
|
||||
// /// <summary>
|
||||
// /// 只更新指定 Key 的 Host,保留原有 ObjUrl。
|
||||
// /// </summary>
|
||||
// void SetHost(string key, string host);
|
||||
|
||||
// /// <summary>
|
||||
// /// 删除运行时覆盖配置。删除后会回退到 Keyed DI 初始配置。
|
||||
// /// </summary>
|
||||
// bool Remove(string key);
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Client
|
||||
{
|
||||
internal class ServerConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务器时间差
|
||||
/// </summary>
|
||||
public static long TimeDifferent { get; internal set; }
|
||||
/// <summary>
|
||||
/// 是否使用新签名算法
|
||||
/// </summary>
|
||||
public static bool IsNewSignatureAuth { get; internal set; } = true;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Store.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务配置默认 Key。
|
||||
/// </summary>
|
||||
public static class ServiceConfigKeys
|
||||
{
|
||||
/// <summary>
|
||||
/// 基础 Store API 使用的默认配置 Key。
|
||||
/// </summary>
|
||||
public const string Default = "Default";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
//using Autofac.Core.Registration;
|
||||
//using Autofac.Features.Indexed;
|
||||
//using MAX.Core.DependencyInjection;
|
||||
//using MAX.Core.Infrastructure;
|
||||
//using System;
|
||||
//using System.Collections.Concurrent;
|
||||
//using System.Collections.Generic;
|
||||
|
||||
//namespace Store.Client
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// 从 Autofac Keyed Service 中获取服务配置。
|
||||
// /// 登录后服务端下发的新地址会保存在运行时配置中,并优先于 Keyed DI 初始配置。
|
||||
// /// </summary>
|
||||
// public sealed class ServiceConfigProvider : IServiceConfigProvider, ISingletonDependency
|
||||
// {
|
||||
// private readonly IIndex<string, IApiServerConfig> _configs;
|
||||
// private readonly ConcurrentDictionary<string, IApiServerConfig> _runtimeConfigs = new ConcurrentDictionary<string, IApiServerConfig>();
|
||||
|
||||
// public ServiceConfigProvider(IIndex<string, IApiServerConfig> configs)
|
||||
// {
|
||||
// _configs = configs ?? throw new ArgumentNullException(nameof(configs));
|
||||
// }
|
||||
|
||||
// public IApiServerConfig Get(string key)
|
||||
// {
|
||||
// if (TryGet(key, out IApiServerConfig config))
|
||||
// {
|
||||
// return config;
|
||||
// }
|
||||
|
||||
// throw new InvalidOperationException($"未注册 Key 为“{key}”的 IApiServerConfig。");
|
||||
// }
|
||||
|
||||
// public bool TryGet(string key, out IApiServerConfig config)
|
||||
// {
|
||||
// config = null;
|
||||
// if (string.IsNullOrWhiteSpace(key))
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// if (_runtimeConfigs.TryGetValue(key, out config))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// try
|
||||
// {
|
||||
// config = _configs[key];
|
||||
// return config != null;
|
||||
// }
|
||||
// catch (KeyNotFoundException)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// catch (ComponentNotRegisteredException)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
// public void Set(string key, IApiServerConfig config)
|
||||
// {
|
||||
// if (string.IsNullOrWhiteSpace(key))
|
||||
// {
|
||||
// throw new ArgumentException("服务配置 Key 不能为空。", nameof(key));
|
||||
// }
|
||||
// if (config == null)
|
||||
// {
|
||||
// throw new ArgumentNullException(nameof(config));
|
||||
// }
|
||||
|
||||
// _runtimeConfigs[key] = config;
|
||||
// }
|
||||
|
||||
// public void Set(string key, string host, string objUrl)
|
||||
// {
|
||||
// Set(key, new ServiceConfig(host, objUrl));
|
||||
// }
|
||||
|
||||
// public void SetHost(string key, string host)
|
||||
// {
|
||||
// string objUrl = TryGet(key, out IApiServerConfig config)
|
||||
// ? config.ObjUrl
|
||||
// : string.Empty;
|
||||
// Set(key, new ServiceConfig(host, objUrl));
|
||||
// }
|
||||
|
||||
// public bool Remove(string key)
|
||||
// {
|
||||
// return !string.IsNullOrWhiteSpace(key) && _runtimeConfigs.TryRemove(key, out _);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,41 @@
|
||||
//using Autofac;
|
||||
//using System;
|
||||
|
||||
//namespace Store.Client
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// IServerConfig 的 Keyed DI 注册扩展。
|
||||
// /// </summary>
|
||||
// public static class ServiceConfigRegistrationExtensions
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 注册指定 Key 的服务配置。
|
||||
// /// </summary>
|
||||
// public static ContainerBuilder RegisterServiceConfig(this ContainerBuilder builder, string key, IServerConfig config)
|
||||
// {
|
||||
// if (builder == null)
|
||||
// {
|
||||
// throw new ArgumentNullException(nameof(builder));
|
||||
// }
|
||||
// if (string.IsNullOrWhiteSpace(key))
|
||||
// {
|
||||
// throw new ArgumentException("服务配置 Key 不能为空。", nameof(key));
|
||||
// }
|
||||
// if (config == null)
|
||||
// {
|
||||
// throw new ArgumentNullException(nameof(config));
|
||||
// }
|
||||
|
||||
// builder.RegisterInstance(config).Keyed<IServerConfig>(key);
|
||||
// return builder;
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 注册指定 Key 的服务配置。
|
||||
// /// </summary>
|
||||
// public static ContainerBuilder RegisterServiceConfig(this ContainerBuilder builder, string key, string host, string objUrl)
|
||||
// {
|
||||
// return builder.RegisterServiceConfig(key, new ServiceConfig(host, objUrl));
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Reference in new issue
Block a user