Minor Possible Problem in Validation List Sort

Minor Possible Problem in Validation List Sort

Old forum URL: forums.lhotka.net/forums/t/4244.aspx


vdhant posted on Saturday, January 26, 2008

Hi guys
In the ValidationRulesManager there are two different AddRule methods, type and untyped. In either case the rule gets added to the list:
        public void AddRule(RuleHandler handler, RuleArgs args, int priority)
        {
            List<IRuleMethod> list = this.GetRulesForProperty(args.PropertyName, true).GetList(false);
            list.Add(new RuleMethod(handler, args, priority));
        }

Now according to the documentation in the 2.1 handbook (and it makes sense) the following should happen when a rule is added the sort is also suppose to be set to false "The Add() method not only adds the item, but also sets _sorted to false, because adding a new item to the list potentially
upsets any pre-existing sort:".

The problem is that the add method that is referred to is that within the rules list is not call by the either of the AddRule methods. So as you can see the in the bolded line above it does not call the RulesList add method, it calls the add method on the list directly and hence the list (after the first rule is added) never gets set to being unsorted, which according to the documentation must occur when the item is added and is necessary for the system to work. So i would imagine that it would look something more like this??

        public void AddRule(RuleHandler handler, RuleArgs args, int priority)
        {
            this.GetRulesForProperty(args.PropertyName, true).Add(new RuleMethod(handler, args, priority));
        }

Now i realise that this mightn't necessarily a problem because the initial sort doesn't occur until it has been used but I just thought i would note the possible discrepancy if it hasn't been noticed before.
Thanks
Anthony

 

Copyright (c) Marimer LLC