private void UpdateModelValueImpl(UpdateModelValueCommand command) { CurrentSpace.UpdateModelValue(command.ModelGuid, command.Name, command.Value); UndoCommand.RaiseCanExecuteChanged(); RedoCommand.RaiseCanExecuteChanged(); }
/// <summary> /// Call this static method to reconstruct a RecordableCommand-derived /// object given an XmlElement that was previously saved with Serialize /// method. This method simply redirects the XmlElement to respective /// RecordableCommand-derived classes based on its type. /// </summary> /// <param name="element">The XmlElement from which the RecordableCommand /// can be reconstructed.</param> /// <returns>Returns the reconstructed RecordableCommand object. If a /// RecordableCommand cannot be reconstructed, this method throws a /// relevant exception.</returns> /// internal static RecordableCommand Deserialize(XmlElement element) { if (string.IsNullOrEmpty(element.Name)) { throw new ArgumentException("XmlElement without name"); } RecordableCommand command = null; switch (element.Name) { case "CreateNodeCommand": command = CreateNodeCommand.DeserializeCore(element); break; case "SelectModelCommand": command = SelectModelCommand.DeserializeCore(element); break; case "CreateNoteCommand": command = CreateNoteCommand.DeserializeCore(element); break; case "SelectInRegionCommand": command = SelectInRegionCommand.DeserializeCore(element); break; case "DragSelectionCommand": command = DragSelectionCommand.DeserializeCore(element); break; case "MakeConnectionCommand": command = MakeConnectionCommand.DeserializeCore(element); break; case "DeleteModelCommand": command = DeleteModelCommand.DeserializeCore(element); break; case "UndoRedoCommand": command = UndoRedoCommand.DeserializeCore(element); break; case "UpdateModelValueCommand": command = UpdateModelValueCommand.DeserializeCore(element); break; } if (null != command) { command.IsInPlaybackMode = true; return(command); } string message = string.Format("Unknown command: {0}", element.Name); throw new ArgumentException(message); }
void UpdateModelValueImpl(UpdateModelValueCommand command) { WorkspaceModel targetWorkspace = CurrentWorkspace; if (!command.WorkspaceGuid.Equals(Guid.Empty)) { targetWorkspace = Workspaces.FirstOrDefault(w => w.Guid.Equals(command.WorkspaceGuid)); } targetWorkspace.UpdateModelValue(command.ModelGuids, command.Name, command.Value); }
public void UpdateModelValueCommand_Constructor() { //Arrange var cbn = CreateCodeBlockNode(); IEnumerable <Guid> modelGuid = new[] { cbn.GUID }; //Act //Executing the overloaded constructors var command1 = new UpdateModelValueCommand(cbn.GUID.ToString(), "nameModel", "valueModel"); var command2 = new UpdateModelValueCommand(modelGuid, "nameModel", "valueModel"); //Assert //Checking that the commands were created correctly Assert.IsNotNull(command1); Assert.IsNotNull(command2); Assert.Throws <NotImplementedException>(() => command1.ToString()); }
private void UpdateModelValueImpl(UpdateModelValueCommand command) { WorkspaceModel targetWorkspace = CurrentWorkspace; if (!command.WorkspaceGuid.Equals(Guid.Empty)) { targetWorkspace = Workspaces.FirstOrDefault(w => w.Guid.Equals(command.WorkspaceGuid)); } try { targetWorkspace?.UpdateModelValue(command.ModelGuids, command.Name, command.Value); } catch (Exception ex) { Logger.LogError(ex.Message); } }
void UpdateModelValueImpl(UpdateModelValueCommand command) { CurrentWorkspace.UpdateModelValue(command.ModelGuid, command.Name, command.Value); }
void UpdateModelValueImpl(UpdateModelValueCommand command) { WorkspaceModel targetWorkspace = CurrentWorkspace; if (!command.WorkspaceGuid.Equals(Guid.Empty)) targetWorkspace = Workspaces.FirstOrDefault(w => w.Guid.Equals(command.WorkspaceGuid)); targetWorkspace.UpdateModelValue(command.ModelGuids, command.Name, command.Value); }
/// <summary> /// Call this static method to reconstruct a RecordableCommand-derived /// object given an XmlElement that was previously saved with Serialize /// method. This method simply redirects the XmlElement to respective /// RecordableCommand-derived classes based on its type. /// </summary> /// <param name="element">The XmlElement from which the RecordableCommand /// can be reconstructed.</param> /// <returns>Returns the reconstructed RecordableCommand object. If a /// RecordableCommand cannot be reconstructed, this method throws a /// relevant exception.</returns> /// internal static RecordableCommand Deserialize(XmlElement element) { if (string.IsNullOrEmpty(element.Name)) { throw new ArgumentException("XmlElement without name"); } RecordableCommand command = null; switch (element.Name) { case "OpenFileCommand": command = OpenFileCommand.DeserializeCore(element); break; case "PausePlaybackCommand": command = PausePlaybackCommand.DeserializeCore(element); break; case "RunCancelCommand": command = RunCancelCommand.DeserializeCore(element); break; case "CreateNodeCommand": command = CreateNodeCommand.DeserializeCore(element); break; case "SelectModelCommand": command = SelectModelCommand.DeserializeCore(element); break; case "CreateNoteCommand": command = CreateNoteCommand.DeserializeCore(element); break; case "SelectInRegionCommand": command = SelectInRegionCommand.DeserializeCore(element); break; case "DragSelectionCommand": command = DragSelectionCommand.DeserializeCore(element); break; case "MakeConnectionCommand": command = MakeConnectionCommand.DeserializeCore(element); break; case "DeleteModelCommand": command = DeleteModelCommand.DeserializeCore(element); break; case "UndoRedoCommand": command = UndoRedoCommand.DeserializeCore(element); break; case "ModelEventCommand": command = ModelEventCommand.DeserializeCore(element); break; case "UpdateModelValueCommand": command = UpdateModelValueCommand.DeserializeCore(element); break; case "ConvertNodesToCodeCommand": command = ConvertNodesToCodeCommand.DeserializeCore(element); break; case "CreateCustomNodeCommand": command = CreateCustomNodeCommand.DeserializeCore(element); break; case "SwitchTabCommand": command = SwitchTabCommand.DeserializeCore(element); break; } if (null != command) { command.IsInPlaybackMode = true; command.Tag = element.GetAttribute("Tag"); return(command); } string message = string.Format("Unknown command: {0}", element.Name); throw new ArgumentException(message); }