// Normally we wouldn't do this in the pattern but the originator itself // can't be found without project-wide knowledge...so we have to do some type-specific // logic. ElementSave GetWhatToApplyTo(UndoObject undoObject) { object parentAsObject = undoObject.Parent; ElementSave parentAsElementSave = parentAsObject as ElementSave; return(parentAsElementSave); //if (undoObject.StateSave != null) //{ // if (parentAsElementSave != null) // { // // for now we will just assume the default state // return parentAsElementSave.DefaultState; // } //} //if (undoObject.Instances != null) //{ // if (parentAsElementSave != null) // { // return parentAsElementSave.Instances; // } //} //return null; }
public static UndoObject CreateUndoObject(StateSave objectToSave, List<InstanceSave> instances, object parent) { StateSave cloned = FileManager.CloneSaveObject(objectToSave); List<InstanceSave> instancesCloned = null; if (instances != null) { instancesCloned = new List<InstanceSave>(); foreach (var instance in instances) { instancesCloned.Add(instance); // no need to clone this, I don't think } } UndoObject undoObject = new UndoObject( cloned, instancesCloned, parent); return undoObject; }
public static UndoObject CreateUndoObject(StateSave objectToSave, List <InstanceSave> instances, object parent) { StateSave cloned = FileManager.CloneSaveObject(objectToSave); List <InstanceSave> instancesCloned = null; if (instances != null) { instancesCloned = new List <InstanceSave>(); foreach (var instance in instances) { instancesCloned.Add(instance); // no need to clone this, I don't think } } UndoObject undoObject = new UndoObject( cloned, instancesCloned, parent); return(undoObject); }
// Normally we wouldn't do this in the pattern but the originator itself // can't be found without project-wide knowledge...so we have to do some type-specific // logic. ElementSave GetWhatToApplyTo(UndoObject undoObject) { object parentAsObject = undoObject.Parent; ElementSave parentAsElementSave = parentAsObject as ElementSave; return parentAsElementSave; //if (undoObject.StateSave != null) //{ // if (parentAsElementSave != null) // { // // for now we will just assume the default state // return parentAsElementSave.DefaultState; // } //} //if (undoObject.Instances != null) //{ // if (parentAsElementSave != null) // { // return parentAsElementSave.Instances; // } //} //return null; }