/// <summary> /// Executes this commmand. /// </summary> /// <remarks></remarks> public override void Execute() { // Verify all [Required] and [Import]ed properties have valid values. this.ValidateObject(); var element = CurrentElement.As <IAbstractEndpointComponents>(); var components = CurrentElement.Root.As <IApplication>().Design.Services.Service.SelectMany(s => s.Components.Component) .Except(element.AbstractComponentLinks.Select(cl => cl.ComponentReference.Value)); var existingServiceNames = components.Select(e => String.Format("{0}.{1}", e.Parent.Parent.InstanceName, e.InstanceName)).ToList(); var viewModel = new ComponentPickerViewModel(existingServiceNames) { Title = "Deploy components..." }; var picker = WindowFactory.CreateDialog <ComponentPicker>(viewModel); var currentEndpoint = CurrentElement.Parent.As <IAbstractEndpoint>(); using (new MouseCursor(Cursors.Arrow)) { if (picker.ShowDialog().GetValueOrDefault()) { foreach (var selectedElement in viewModel.SelectedItems) { var selectedCompoenent = default(NServiceBusStudio.IComponent); if (existingServiceNames.Contains(selectedElement)) { selectedCompoenent = components.FirstOrDefault(e => String.Equals(String.Format("{0}.{1}", e.Parent.Parent.InstanceName, e.InstanceName), selectedElement, StringComparison.InvariantCultureIgnoreCase)); } selectedCompoenent.DeployTo(currentEndpoint); //var link = CurrentElement.As<IAbstractEndpointComponents>().CreateComponentLink(selectedCompoenent.InstanceName, e => e.ComponentReference.Value = selectedCompoenent); //link.ComponentReference.Value.EndpointDefined(currentEndpoint); } } } }
/// <summary> /// Executes this commmand. /// </summary> /// <remarks></remarks> public override void Execute() { // Verify all [Required] and [Import]ed properties have valid values. this.ValidateObject(); var element = CurrentElement.As<IAbstractEndpointComponents>(); var components = CurrentElement.Root.As<IApplication>().Design.Services.Service.SelectMany(s => s.Components.Component) .Except(element.AbstractComponentLinks.Select(cl => cl.ComponentReference.Value)); var existingServiceNames = components.Select(e => String.Format ("{0}.{1}", e.Parent.Parent.InstanceName, e.InstanceName)).ToList(); var viewModel = new ComponentPickerViewModel(existingServiceNames) { Title = "Deploy components..." }; var picker = WindowFactory.CreateDialog<ComponentPicker>(viewModel); var currentEndpoint = CurrentElement.Parent.As<IAbstractEndpoint>(); using (new MouseCursor(Cursors.Arrow)) { if (picker.ShowDialog().GetValueOrDefault()) { foreach (var selectedElement in viewModel.SelectedItems) { var selectedCompoenent = default(NServiceBusStudio.IComponent); if (existingServiceNames.Contains(selectedElement)) { selectedCompoenent = components.FirstOrDefault(e => String.Equals(String.Format ("{0}.{1}", e.Parent.Parent.InstanceName, e.InstanceName), selectedElement, StringComparison.InvariantCultureIgnoreCase)); } selectedCompoenent.DeployTo(currentEndpoint); //var link = CurrentElement.As<IAbstractEndpointComponents>().CreateComponentLink(selectedCompoenent.InstanceName, e => e.ComponentReference.Value = selectedCompoenent); //link.ComponentReference.Value.EndpointDefined(currentEndpoint); } } } }