private ObservableCollection<SelectItemViewModel> GetComponentsCollection(IEnumerable<IComponent> components, ICommand command) { var service = command.GetParentService(); var allDeployedComponents = service.Parent.Parent .Endpoints.GetAll() .SelectMany(ep => ep.EndpointComponents.AbstractComponentLinks.Where(l => l.ComponentReference.Value.Parent.Parent == service)) .ToDictionary(l => l.ComponentReference.Value, l => l.ParentEndpointComponents.ParentEndpoint); return new ObservableCollection<SelectItemViewModel>( components .Select( c => { IAbstractEndpoint endpoint; return new SelectItemViewModel { Item = c, Name = string.Format( CultureInfo.CurrentCulture, "{0} ({1})", c.InstanceName, (allDeployedComponents.TryGetValue(c, out endpoint) ? endpoint.InstanceName : "undeployed")), IsSelected = c.Publishes.CommandLinks.All(l => l.CommandReference.Value == command) && !c.Publishes.EventLinks.Any() && c.Subscribes.ProcessedCommandLinks.All(l => l.CommandReference.Value == command) && !c.Publishes.EventLinks.Any() }; }) .OrderBy(n => n.Name)); }
private ObservableCollection <SelectItemViewModel> GetComponentsCollection(IEnumerable <IComponent> components, ICommand command) { var service = command.GetParentService(); var allDeployedComponents = service.Parent.Parent .Endpoints.GetAll() .SelectMany(ep => ep.EndpointComponents.AbstractComponentLinks.Where(l => l.ComponentReference.Value.Parent.Parent == service)) .ToDictionary(l => l.ComponentReference.Value, l => l.ParentEndpointComponents.ParentEndpoint); return(new ObservableCollection <SelectItemViewModel>( components .Select( c => { IAbstractEndpoint endpoint; return new SelectItemViewModel { Item = c, Name = string.Format( CultureInfo.CurrentCulture, "{0} ({1})", c.InstanceName, (allDeployedComponents.TryGetValue(c, out endpoint) ? endpoint.InstanceName : "undeployed")), IsSelected = c.Publishes.CommandLinks.All(l => l.CommandReference.Value == command) && !c.Publishes.EventLinks.Any() && c.Subscribes.ProcessedCommandLinks.All(l => l.CommandReference.Value == command) && !c.Publishes.EventLinks.Any() }; }) .OrderBy(n => n.Name))); }