You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

43 lines
1.4 KiB

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CheckConfig
{
public class CheckConfigStrategyFactory
{
private static Dictionary<string, ConfigStrategy> MapDesc = new Dictionary<string, ConfigStrategy>();
public static CheckCofigDef cofigDef = new CheckCofigDef();
public static ConfigStrategy GetConfigStrategy(string type)
{
return MapDesc[type];
}
public static void Register(string type, ConfigStrategy configStrategy)
{
if(configStrategy==null)
throw new ArgumentNullException("configStrategy 不能为空");
if(!MapDesc.ContainsKey(type))
MapDesc.Add(type, configStrategy);
}
public static void InitConfigDef(string fileName)
{
if (!File.Exists(fileName))
{
return;
}
try
{
cofigDef = Sog.JsonConfig.parseFileLitJson<CheckCofigDef>(fileName);
}
catch (Exception ex)
{
Console.WriteLine("CheckConfigStrategyFactory.InitConfigDef Exception: {0}", ex.Message);
Console.WriteLine("CheckConfigStrategyFactory.InitConfigDef StackTrace: {0}", ex.StackTrace);
}
}
}
}