pGina.Plugin.UsernameMod.Rules.ListOfRules.MoveUp C# (CSharp) Method

MoveUp() public method

Moves the rule at the specified index up one (e.g. index=2 becomes index=1). Will not move an item if it's at the top, or if it will be above a rule with an earlier step. (e.g. A gateway rule can not be above a authorization rule)
public MoveUp ( int index ) : bool
index int
return bool
        public bool MoveUp(int index)
        {
            IUsernameRule rule = list.ElementAt(index);
            if(index > 0){
                if (list.ElementAt(index - 1).stage == rule.stage)
                {
                    list.RemoveAt(index);
                    list.Insert(index - 1, rule);
                    return true;
                }
            }
            return false;
        }