/// <summary> /// Executes this commmand. /// </summary> /// <remarks></remarks> public override void Execute() { // Verify all [Required] and [Import]ed properties have valid values. this.ValidateObject(); var services = CurrentElement.Parent.Parent.Parent.Parent.Service; var existingServiceNames = services.Select(e => e.InstanceName).ToList(); var viewModel = new ServicePickerViewModel(existingServiceNames); var picker = WindowFactory.CreateDialog<ServicePicker>(viewModel); using (new MouseCursor(Cursors.Arrow)) { if (picker.ShowDialog().GetValueOrDefault()) { foreach (var selectedElement in viewModel.SelectedItems) { var selectedService = services.FirstOrDefault(e => string.Equals(e.InstanceName, selectedElement, StringComparison.InvariantCultureIgnoreCase)); if (selectedService == null) { selectedService = CurrentElement.Parent.Parent.Parent.Parent.CreateService(selectedElement); } var component = selectedService.Components.CreateComponent(string.Format("{0}Handler", CurrentElement.InstanceName)); component.Subscribes.CreateLink(CurrentElement); } } } // TODO: Implement command automation code // TODO: Use tracer.Warning() to note expected and recoverable errors // TODO: Use tracer.Verbose() to note internal execution logic decisions // TODO: Use tracer.Info() to note key results of execution // TODO: Raise exceptions for all other errors }
/// <summary> /// Executes this commmand. /// </summary> /// <remarks></remarks> public override void Execute() { // Verify all [Required] and [Import]ed properties have valid values. this.ValidateObject(); var services = CurrentElement.Parent.Parent.Parent.Parent.Service; var existingServiceNames = services.Select(e => e.InstanceName).ToList(); var viewModel = new ServicePickerViewModel(existingServiceNames); var picker = WindowFactory.CreateDialog <ServicePicker>(viewModel); using (new MouseCursor(Cursors.Arrow)) { if (picker.ShowDialog().GetValueOrDefault()) { foreach (var selectedElement in viewModel.SelectedItems) { var selectedService = services.FirstOrDefault(e => string.Equals(e.InstanceName, selectedElement, StringComparison.InvariantCultureIgnoreCase)); if (selectedService == null) { selectedService = CurrentElement.Parent.Parent.Parent.Parent.CreateService(selectedElement); } var component = selectedService.Components.CreateComponent(string.Format("{0}Handler", CurrentElement.InstanceName)); component.Subscribes.CreateLink(CurrentElement); } } } // TODO: Implement command automation code // TODO: Use tracer.Warning() to note expected and recoverable errors // TODO: Use tracer.Verbose() to note internal execution logic decisions // TODO: Use tracer.Info() to note key results of execution // TODO: Raise exceptions for all other errors }