public void Group() { lock (_groupingLock) { if (_hasGrouped) { return; } _calls.Where(x => x.MessageType.IsConcrete()) .GroupBy(x => x.MessageType) .Select(group => new HandlerChain(group)) .Each(chain => { _chains = _chains.AddOrUpdate(chain.MessageType, chain); }); _calls.Where(x => !x.MessageType.IsConcrete()) .Each(call => { Chains .Where(c => call.CouldHandleOtherMessageType(c.MessageType)) .Each(c => { c.AddAbstractedHandler(call); }); }); _hasGrouped = true; } }
public List <TagViewModel> GetCommonTags() { if (SelectedEntries == null || SelectedEntries.Count() == 0) { return(new List <TagViewModel>()); } var images = GetAllImages(SelectedEntries); if (images.Count() == 0) { return(new List <TagViewModel>()); } var firstEntry = images.First(); IEnumerable <TagViewModel> temp = Chains.Where(a => a.ImageID == firstEntry.ID).Select(a => a.Tag).ToList(); foreach (var image in images) { IEnumerable <TagViewModel> tags = Chains.Where(a => a.ImageID == image.ID).Select(a => a.Tag).ToList(); temp = temp.Intersect(tags).ToList(); } return(temp.ToList()); }
public void RemoveByImage(ImageViewModel image) { if (image == null) { throw new ArgumentNullException("image == null"); } ImageTagFacade.DeleteWhereIDIs(image.ID); var removeList = Chains.Where(it => it.ImageID == image.ID).ToList(); foreach (var remove in removeList) { Chains.Remove(remove); } }
private void RecaclulateCommonTags(EntryViewModel add) { var images = GetAllImages(new EntryViewModel[] { add }); try { if (SelectedEntries.Count == 0 && images.Count() > 0) { IEnumerable <TagViewModel> tags = Chains.Where(a => a.ImageID == images.First().ID).Select(a => a.Tag).ToList(); SelectedEntityTags.AddRange(tags); } foreach (var image in images) { IEnumerable <TagViewModel> tags = Chains.Where(a => a.ImageID == image.ID).Select(a => a.Tag).ToList(); SelectedEntityTags = SelectedEntityTags.Intersect(tags).ToList(); } } catch (InvalidOperationException e) { s_logger.Warn(e); } }