Esempio n. 1
0
        private RulesExceptionListContainer FindRulesExceptionListContainer(string[] keySplit, int index, KeyValuePair <string, List <object> > error, RulesException rulesException, List <RulesExceptionListContainer> rulesExceptionListContainers)
        {
            var rulesExceptionListContainer = rulesExceptionListContainers.SingleOrDefault(x => x.KeyIndex == keySplit[index] || (x.Key == "" && x.KeyIndex == keySplit[index]));

            if (rulesExceptionListContainer != null && rulesExceptionListContainer.Index.HasValue)
            {
                var nextIndex = index + 1;
                var findRulesExceptionListContainer = FindRulesExceptionListContainer(keySplit, nextIndex, error, rulesException, rulesExceptionListContainer.RulesExceptionListContainers);
                if (findRulesExceptionListContainer != null)
                {
                    return(findRulesExceptionListContainer);
                }
                else if (keySplit[nextIndex].EndsWith("]"))
                {
                    var newRulesExceptionListContainers = new RulesExceptionListContainer(rulesException);
                    rulesExceptionListContainer.RulesExceptionListContainers.Add(newRulesExceptionListContainers);
                    findRulesExceptionListContainer = FindRulesExceptionListContainer(keySplit, nextIndex, error, rulesException, rulesExceptionListContainer.RulesExceptionListContainers);
                    if (findRulesExceptionListContainer != null)
                    {
                        return(findRulesExceptionListContainer);
                    }
                }
            }
            return(rulesExceptionListContainer);
        }
Esempio n. 2
0
        private void FindAndAddRulesExceptionListContainer(string key, string[] keySplit, KeyValuePair <string, List <object> > error, RulesException rulesException)
        {
            var rulesExceptionListContainer = FindRulesExceptionListContainer(keySplit, 0, error, rulesException, RulesExceptionListContainers);

            if (rulesExceptionListContainer == null)
            {
                var newRulesExceptionListContainers = new RulesExceptionListContainer(rulesException);
                newRulesExceptionListContainers.AddError(error);
                RulesExceptionListContainers.Add(newRulesExceptionListContainers);
            }
            else
            {
                rulesExceptionListContainer.AddError(new KeyValuePair <string, List <object> >(key.Replace(rulesExceptionListContainer.KeyIndex + ".", ""), error.Value));
            }
        }