예제 #1
0
        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);
        }
예제 #2
0
        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);
        }