|
@@ -1,96 +1,96 @@
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
-using WingServerCommon.Config.Parameters;
|
|
|
-
|
|
|
-namespace WingServerCommon.Config
|
|
|
-{
|
|
|
- /// <summary>
|
|
|
- /// This class will load a glabal server configuration
|
|
|
- /// </summary>
|
|
|
- public class ConfigurationManager
|
|
|
- {
|
|
|
- private static IEnumerable<IParameter> _parameters;
|
|
|
- /// <summary>
|
|
|
- /// The listening server gateway port
|
|
|
- /// </summary>
|
|
|
- /// <value></value>
|
|
|
- public static int ServerGatewayPort {get; private set;}
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Static server params -- TODO Maybe we don't need this one
|
|
|
- /// </summary>
|
|
|
- /// <value></value>
|
|
|
- public static string StaticServerParams {get; private set;}
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Log settings from configuration file
|
|
|
- /// </summary>
|
|
|
- /// <value></value>
|
|
|
- public static LogSettings? LogSettings {get; private set;}
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Email settings from configuration file
|
|
|
- /// </summary>
|
|
|
- /// <value></value>
|
|
|
- public static EmailSettings? EmailSettings {get; private set;}
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Storage settings is from configuration file
|
|
|
- /// </summary>
|
|
|
- /// <value></value>
|
|
|
- public static StorageSettings? StorageSettings {get; private set;}
|
|
|
- static ConfigurationManager()
|
|
|
- {
|
|
|
- var configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"appsettings.json");
|
|
|
- _parameters = ParameterSerializer.Deserialize(configFilePath);
|
|
|
-
|
|
|
- LoadConfiguration();
|
|
|
- }
|
|
|
-
|
|
|
- private static T GetParammeter<T>(string sectionName, string paramName) where T: class
|
|
|
- {
|
|
|
- var parameter = _parameters.FirstOrDefault(x=>x.Section == sectionName && x.Name == paramName) as T;
|
|
|
- if (parameter != null)
|
|
|
- {
|
|
|
- return parameter;
|
|
|
- }
|
|
|
-
|
|
|
- throw new System.ArgumentException($"{sectionName} - {paramName} not set correct");
|
|
|
- }
|
|
|
-
|
|
|
- private static void LoadConfiguration()
|
|
|
- {
|
|
|
- ServerGatewayPort = GetParammeter<IntParameter>("Gateway","port").Value;
|
|
|
-
|
|
|
- EmailSettings = new EmailSettings(); //TODO load from settings
|
|
|
-
|
|
|
- //TODO load log settings
|
|
|
-
|
|
|
- LoadStorageConfig();
|
|
|
-
|
|
|
- //TODO others
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 加载 存储服务 配置
|
|
|
- /// </summary>
|
|
|
- /// <returns></returns>
|
|
|
- private static void LoadStorageConfig()
|
|
|
- {
|
|
|
- StorageSettings = new StorageSettings()
|
|
|
- {
|
|
|
- DefaultStorageServer = GetParammeter<StringParameter>("Storage","StorageServer").Value == "Vinno" ?
|
|
|
- StorageServerEnum.Vinno : StorageServerEnum.Tencent,
|
|
|
- SliceSizeForUpload = GetParammeter<IntParameter>("Storage","SliceSizeForUpload").Value,
|
|
|
- DivisionForUpload = GetParammeter<IntParameter>("Storage","DivisionForUpload").Value,
|
|
|
- CFSServerUrl = GetParammeter<StringParameter>("Storage","CFSServerUrl").Value,
|
|
|
- CDNServerUrl = GetParammeter<StringParameter>("Storage","CDNServerUrl").Value,
|
|
|
- Bucket = GetParammeter<StringParameter>("Storage","Bucket").Value,
|
|
|
- Sercret = GetParammeter<StringParameter>("Storage","Sercret").Value,
|
|
|
- AppId = GetParammeter<StringParameter>("Storage","AppId").Value,
|
|
|
- };
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using WingServerCommon.Config.Parameters;
|
|
|
+
|
|
|
+namespace WingServerCommon.Config
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// This class will load a glabal server configuration
|
|
|
+ /// </summary>
|
|
|
+ public class ConfigurationManager
|
|
|
+ {
|
|
|
+ private static IEnumerable<IParameter> _parameters;
|
|
|
+ /// <summary>
|
|
|
+ /// The listening server gateway port
|
|
|
+ /// </summary>
|
|
|
+ /// <value></value>
|
|
|
+ public static int ServerGatewayPort {get; private set;}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Static server params -- TODO Maybe we don't need this one
|
|
|
+ /// </summary>
|
|
|
+ /// <value></value>
|
|
|
+ public static string StaticServerParams {get; private set;}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Log settings from configuration file
|
|
|
+ /// </summary>
|
|
|
+ /// <value></value>
|
|
|
+ public static LogSettings? LogSettings {get; private set;}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Email settings from configuration file
|
|
|
+ /// </summary>
|
|
|
+ /// <value></value>
|
|
|
+ public static EmailSettings? EmailSettings {get; private set;}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Storage settings is from configuration file
|
|
|
+ /// </summary>
|
|
|
+ /// <value></value>
|
|
|
+ public static StorageSettings? StorageSettings {get; private set;}
|
|
|
+ static ConfigurationManager()
|
|
|
+ {
|
|
|
+ var configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"appsettings.json");
|
|
|
+ _parameters = ParameterSerializer.Deserialize(configFilePath);
|
|
|
+
|
|
|
+ LoadConfiguration();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static T GetParammeter<T>(string sectionName, string paramName) where T: class
|
|
|
+ {
|
|
|
+ var parameter = _parameters.FirstOrDefault(x=>x.Section == sectionName && x.Name == paramName) as T;
|
|
|
+ if (parameter != null)
|
|
|
+ {
|
|
|
+ return parameter;
|
|
|
+ }
|
|
|
+
|
|
|
+ throw new System.ArgumentException($"{sectionName} - {paramName} not set correct");
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void LoadConfiguration()
|
|
|
+ {
|
|
|
+ ServerGatewayPort = GetParammeter<IntParameter>("Gateway","port").Value;
|
|
|
+
|
|
|
+ EmailSettings = new EmailSettings(); //TODO load from settings
|
|
|
+
|
|
|
+ //TODO load log settings
|
|
|
+
|
|
|
+ LoadStorageConfig();
|
|
|
+
|
|
|
+ //TODO others
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 加载 存储服务 配置
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ private static void LoadStorageConfig()
|
|
|
+ {
|
|
|
+ StorageSettings = new StorageSettings()
|
|
|
+ {
|
|
|
+ DefaultStorageServer = GetParammeter<StringParameter>("Storage","StorageServer").Value == "Vinno" ?
|
|
|
+ StorageServerEnum.Vinno : StorageServerEnum.Tencent,
|
|
|
+ SliceSizeForUpload = GetParammeter<IntParameter>("Storage","SliceSizeForUpload").Value,
|
|
|
+ DivisionForUpload = GetParammeter<IntParameter>("Storage","DivisionForUpload").Value,
|
|
|
+ CFSServerUrl = GetParammeter<StringParameter>("Storage","CFSServerUrl").Value,
|
|
|
+ CDNServerUrl = GetParammeter<StringParameter>("Storage","CDNServerUrl").Value,
|
|
|
+ Bucket = GetParammeter<StringParameter>("Storage","Bucket").Value,
|
|
|
+ Sercret = GetParammeter<StringParameter>("Storage","Sercret").Value,
|
|
|
+ AppId = GetParammeter<StringParameter>("Storage","AppId").Value,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
|