SortInstructionSaves() public method

public SortInstructionSaves ( List customVariables ) : void
customVariables List
return void
        public static void SetValue(this StateSave stateSave, string variableName, object valueToSet)
        {
#if GLUE
            if (variableName.Contains(" set in "))
            {
                string withoutSpace = variableName.Substring(0, variableName.IndexOf(' '));

                DialogResult result =
                    MessageBox.Show("The variable " + withoutSpace + " is set in other categories that do not share states.  Are you sure you want to set it?", "Set variable?", MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    variableName = withoutSpace;
                }
            }
#endif
            bool wasFound = false;

            // See if there is an instructionD

            #region Set the existing instruction's value if there is one already

            foreach (InstructionSave instructionSave in stateSave.InstructionSaves)
            {
                if (instructionSave.Member == variableName)
                {
                    wasFound = true;
                    instructionSave.Value = valueToSet;
                    break;
                }
            }

            #endregion

            if (!wasFound)
            {
                IElement container = ObjectFinder.Self.GetElementContaining(stateSave);

                CustomVariable variable = null;

                foreach (CustomVariable containedVariable in container.CustomVariables)
                {
                    if (containedVariable.Name == variableName)
                    {
                        variable = containedVariable;
                        break;
                    }
                }



                InstructionSave instructionSave = new InstructionSave();
                instructionSave.Value = valueToSet; // make it the default

                instructionSave.Type   = valueToSet.GetType().Name;
                instructionSave.Member = variableName;
                // Create a new instruction

                stateSave.InstructionSaves.Add(instructionSave);

                stateSave.SortInstructionSaves(container.CustomVariables);
            }
        }