public void AddNewOperation(string operationName) { NewOperationCommand c = (NewOperationCommand)NewOperationCommandFactory.Factory().Create(DiagramController.ModelController); if (!String.IsNullOrEmpty(operationName)) { c.Name = operationName; } else { c.Name = NameSuggestor <Operation> .SuggestUniqueName(Class.Operations, "Operation", operation => operation.Name); } c.Owner = Class; c.Execute(); }
public override void Execute(object parameter) { Element element; MacroCommand <DiagramController> command = MacroCommandFactory <DiagramController> .Factory().Create(ActiveDiagramView.Controller); command.Description = CommandDescription.ADD_OPERATION; foreach (ISelectable item in ActiveDiagramView.SelectedItems) { if (item is XCaseViewBase && (element = (item as XCaseViewBase).Controller.Element) is IHasOperations) { NewOperationCommand c = NewOperationCommandFactory.Factory().Create(ActiveDiagramView.Controller.ModelController) as NewOperationCommand; c.Owner = element as IHasOperations; c.Name = NameSuggestor <Operation> .SuggestUniqueName((element as IHasOperations).Operations, "Operation", property => property.Name); command.Commands.Add(c); } } if (command.Commands.Count > 0) { command.Execute(); } }