Beispiel #1
0
        internal void CancelSavedState()
        {
            if (m_stateStack.Count == 0)
            {
                return;
            }

            Dictionary <string, object> state = m_stateStack.Pop();
            Type ct;

            for (ct = GetType(); ct != typeof(Robot); ct = ct.BaseType)
            {
                FieldInfo[] fields = ct.GetFields(
                    BindingFlags.NonPublic |
                    BindingFlags.Public |
                    BindingFlags.Instance);

                foreach (FieldInfo field in fields)
                {
                    if (field.DeclaringType != ct)
                    {
                        continue;
                    }

                    if (IsNotUndoableField(field))
                    {
                        continue;
                    }

                    string name = ct.Name + "!" + field.Name;

                    if (field.GetType().IsSubclassOf(typeof(Robot)))
                    {
                        Robot robo = (Robot)state[name];
                        robo.CancelSavedState();
                    }
                    else if (field.GetType().IsSubclassOf(typeof(IRobotList)))
                    {
                        IRobotList rl = (IRobotList)state[name];
                        rl.CancelSavedState();
                    }
                }
            }
        }
Beispiel #2
0
        public void EndEdit()
        {
            IRobotList irl = this; // C# is retarted.

            irl.CancelSavedState();
        }