Ejemplo n.º 1
0
        /// <summary>
        /// Registers the inverse change (READY TO BE UNDONE) of a supplied controlled collection and its owning instance, to be undone/redone in the future.
        /// This must happen  as part of a grouping combined variation (a command being performed).
        /// Also, it will not be performed if already an undo/redo operation is running.
        /// </summary>
        public static void RegisterInverseCollectionChange(IModelEntity Instance, EditableCollection SourceCollection, char AlterCode, params object[] Parameters)
        {
            if (Instance == null || Instance.EditEngine == null ||
                Instance.EditEngine.ExecutionStatus != EExecutionStatus.Running)
            {
                return;
            }

            // If no engine controlling or not within command variation declaration then abandon.
            if (!Instance.EditEngine.IsVariating)
            {
                //T Console.WriteLine("No variating at collection change.");
                return;
            }

            // IMPORTANT: EDIT-ENGINES MUST MATCH FOR CHANGING VALUES.
            if (Instance.EditEngine != ActiveEntityEditor)
            {
                throw new UsageAnomaly("Active Entity-Editor differs (for collection) from that of the changing Entity '" + Instance.ToStringAlways() + "'.");
            }

            // Stores the variation into the command being declared.
            var MemberDef = SourceCollection.VariatingInstance.ClassDefinition.GetMemberDef(SourceCollection.Name, false);

            Instance.EditEngine.StoreVariation(new CollectionVariation(SourceCollection, AlterCode, Parameters),
                                               (MemberDef != null && MemberDef.ChangesExistenceStatus));
        }
Ejemplo n.º 2
0
        // ---------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Registers the inverse assignment (READY TO BE UNDONE) of a supplied controlled property and its owning instance, to be undone/redone in the future.
        /// This must happen  as part of a grouping combined variation (a command being performed).
        /// Also, it will not be performed if already an undo/redo operation is running.
        /// </summary>
        internal static void RegisterInverseAssignment(MModelPropertyDefinitor SourcePropertyDef, IModelEntity Instance, object Value)
        {
            // If no engine controlling or not within command variation declaration then abandon.
            if (Instance.EditEngine == null || Instance.EditEngine.ExecutionStatus != EExecutionStatus.Running)
            {
                return;
            }

            if (!Instance.EditEngine.IsVariating)
            {
                //T Console.WriteLine("No variating at property change.");
                return;
            }

            // IMPORTANT: EDIT-ENGINES MUST MATCH FOR CHANGING VALUES.
            if (Instance.EditEngine != ActiveEntityEditor)
            {
                throw new UsageAnomaly("Active Entity-Editor differs (for assignment) from that of the changing Entity '" + Instance.ToStringAlways() + "'.");
            }

            // Stores the variation into the command being declared.
            Instance.EditEngine.StoreVariation(new AssignmentVariation(SourcePropertyDef, Instance, Value), SourcePropertyDef.ChangesExistenceStatus);
        }