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 MapDesc = new Dictionary(); 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(fileName); } catch (Exception ex) { Console.WriteLine("CheckConfigStrategyFactory.InitConfigDef Exception: {0}", ex.Message); Console.WriteLine("CheckConfigStrategyFactory.InitConfigDef StackTrace: {0}", ex.StackTrace); } } } }