lith 4 gadi atpakaļ
vecāks
revīzija
ecfa4a6eb4

+ 3 - 4
dotnet/Vit/Vit.Core/Vit.Core/Util/ConfigurationManager/ConfigurationManager.cs

@@ -6,11 +6,11 @@ namespace Vit.Core.Util.ConfigurationManager
     public class ConfigurationManager: JsonFile
     {
         #region Instance        
-        private static ConfigurationManager instance;
+        private static JsonFile instance;
         /// <summary>
         /// 获取appsettings.json中的配置
         /// </summary>
-        public static ConfigurationManager Instance
+        public static JsonFile Instance
         {
             get { return instance ?? (instance = new ConfigurationManager()); }
             set { instance = value; }
@@ -22,8 +22,7 @@ namespace Vit.Core.Util.ConfigurationManager
         const string fileName = "appsettings.json";
         protected static string GetDefaultPath()
         {
-            return fileName;
-            //return Path.Combine(AppContext.BaseDirectory , fileName);
+            return fileName; 
         }
 
  

+ 8 - 5
dotnet/Vit/Vit.Core/Vit.Core/Util/ConfigurationManager/JsonFile.cs

@@ -56,10 +56,11 @@ namespace Vit.Core.Util.ConfigurationManager
         /// <param name="configPath"></param>
         public JsonFile(string configPath)
         {
-            //if (!Path.IsPathRooted(configPath)) 
-            //{
-                configPath = CommonHelp.GetAbsPath(configPath);
-            //} 
+            if (string.IsNullOrEmpty(configPath)) return;
+
+
+            configPath = CommonHelp.GetAbsPath(configPath);
+
             this.configPath = configPath;
             RefreshConfiguration();
         }
@@ -68,7 +69,7 @@ namespace Vit.Core.Util.ConfigurationManager
         /// 通过相对路径加载json文件
         /// </summary>
         /// <param name="path">如: new []{"Data","sqler.json"}</param>
-        public JsonFile(params string[] path ):this(CommonHelp.GetAbsPath(path))
+        public JsonFile(params string[] path ):this(path.Length==0?null:CommonHelp.GetAbsPath(path))
         {
         }
 
@@ -107,6 +108,8 @@ namespace Vit.Core.Util.ConfigurationManager
         /// </summary>
         public virtual void SaveToFile()
         {
+            if (string.IsNullOrEmpty(configPath)) return;
+
             try
             {
                 string dir = Path.GetDirectoryName(configPath);

+ 83 - 0
dotnet/Vit/Vit.WebHost/appsettings.json

@@ -0,0 +1,83 @@
+{
+  "Sers": {
+
+    /* 网关配置 */
+    "Gateway": {
+ 
+
+      "WebHost": {
+
+        /* url,可多个 */
+        "urls": [ "http://*:4582" ],
+
+        /* 是否允许跨域访问,默认true */
+        "allowAnyOrigin": true,
+
+        /* http回应中的默认Content-Type。若不指定则默认为 "application/json; charset="+Serialization.Instance.charset  */
+        "//ResponseDefaultContentType": "application/json; charset=UTF-8",
+
+
+        /* 映射静态文件。若不指定则不映射静态文件 */
+        "//staticFiles": {
+
+          /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则为默认路径(wwwroot)。demo:"wwwroot/demo" */
+          "rootPath": "wwwroot",
+
+          /* 默认页面(可不指定)。An ordered list of file names to select by default. List length and ordering  may affect performance */
+          //"defaultFileNames": [],
+
+          /* 是否可浏览目录(default false)。Enables directory browsing */
+          //"useDirectoryBrowser": false,
+
+          /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
+          "contentTypeMapFile": "contentTypeMap.json",
+
+          /* 回应静态文件时额外添加的http回应头。可不指定。 */
+          "responseHeaders": {
+
+            //设置浏览器静态文件缓存3600秒
+            "Cache-Control": "public,max-age=3600"
+          }
+        }
+
+      }
+
+    }
+  },
+
+
+  /* Vit工具配置,可不指定 */
+  "Vit": {
+
+    /* 日志配置,可不指定 */
+    "Logger": {
+      /* print the log to console. default:false  */
+      "PrintToConsole": true
+    },
+
+
+    /* 序列化配置,可不指定 */
+    "Serialization": {
+      /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */
+      "Encoding": "UTF8",
+
+      /* 时间序列化格式。可不指定,默认 "yyyy-MM-dd HH:mm:ss" */
+      "DateTimeFormat": "yyyy-MM-dd HH:mm:ss"
+    },
+
+
+    "//Kestrel": {
+      /* (int64) the maximum allowed size of any request body in bytes.  When set to null, the maximum request body size is unlimited. */
+      "MaxRequestBodySize": 2000000000,
+
+      /* (int32) A limit on the length of individual form values. Forms containing values that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
+      "ValueLengthLimit": 2000000000,
+
+      /* (int64) A limit for the length of each multipart body. Forms sections that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
+      "MultipartBodyLengthLimit": 2000000000
+    }
+
+  }
+
+
+}

+ 4 - 0
dotnet/Vit/Vit.WebHost/contentTypeMap.json

@@ -0,0 +1,4 @@
+{
+  /* wwwroot静态文件类型映射配置,可不指定  */
+  ".json": "application/json"
+}