public static RuleSet LoadJson ( [NotNull] string fileName ) { string text = File.ReadAllText(fileName); JObject obj = JObject.Parse(text); RuleSet result = new RuleSet(); List <IrbisRule> rules = new List <IrbisRule>(); foreach (JToken o in obj["rules"]) { string name = o.ToString(); IrbisRule rule = GetRule(name); if (rule != null) { rules.Add(rule); } } result.Rules = rules.ToArray(); return(result); }
public static IrbisRule GetRule ( [NotNull] string name ) { Type ruleType; if (!_registeredRules.TryGetValue ( name, out ruleType) ) { return(null); } IrbisRule result = (IrbisRule)Activator.CreateInstance ( ruleType ); return(result); }