47 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
| using System.Collections.Generic;
 | |
| using System.Configuration;
 | |
| using Microsoft.Extensions.Configuration;
 | |
| using Microsoft.Extensions.Configuration.Json;
 | |
| 
 | |
| namespace IRaCIS.Application
 | |
| {
 | |
|     //public class WebAppConfig
 | |
|     //{
 | |
|     //    public static string RootUrl = ConfigurationManager.AppSettings["rootUrl"].ToString();
 | |
|     //    public static string CodePrefix = ConfigurationManager.AppSettings["CodePrefix"].ToString();
 | |
|     //    public static string UserCodePrefix = ConfigurationManager.AppSettings["UserCodePrefix"].ToString();
 | |
|     //    public static string VisitPlanNumPrefix = ConfigurationManager.AppSettings["VisitPlanNumPrefix"].ToString();
 | |
| 
 | |
|     //    public static int CodeLength { get; private set; }
 | |
|     //    public static List<string> ExcludeCodeList { get; private set; }
 | |
| 
 | |
|     //}
 | |
| 
 | |
| 
 | |
|     // .net core 迁移替换
 | |
|     public class WebAppConfig
 | |
|     {
 | |
|         public static string RootUrl { get; set; }
 | |
|         public static string CodePrefix { get; set; }
 | |
|         public static string UserCodePrefix { get; set; }
 | |
|         public static string VisitPlanNumPrefix { get; set; }
 | |
| 
 | |
|         public static int CodeLength { get; private set; }
 | |
|         public static List<string> ExcludeCodeList { get; private set; }
 | |
|         static WebAppConfig()
 | |
|         {
 | |
|             var configuration = new ConfigurationBuilder()
 | |
|                 .Add(new JsonConfigurationSource { Path = "appsettings.json", ReloadOnChange = true })
 | |
|                 .Build();
 | |
| 
 | |
|             RootUrl = configuration.GetSection("RootUrl").Value;
 | |
| 
 | |
|             CodePrefix = configuration.GetSection("CodePrefix").Value;
 | |
| 
 | |
|             UserCodePrefix = configuration.GetSection("UserCodePrefix").Value;
 | |
| 
 | |
|             VisitPlanNumPrefix = configuration.GetSection("VisitPlanNumPrefix").Value;
 | |
|         }
 | |
| 
 | |
|     }
 | |
| } |