private bool HasSortPreferenceWith(SortedTreeNode <IdType, DataType> a, GetCollection getCollection, SortedTreeNode <IdType, DataType> b) { var collection = getCollection.Invoke(a); if (collection.Count == 0) { return(false); } if (collection.Contains(b.Id)) { return(true); } foreach (IdType aDependency in collection) { var aDep = KnownNodes[aDependency]; if (HasSortPreferenceWith(aDep, getCollection, b)) { return(true); } } return(false); }
private bool HasSortPreferenceWith(SortedTreeNode <IdType, DataType> a, GetCollection getCollection, SortedTreeNode <IdType, DataType> b) { IList <IdType> collection = getCollection.Invoke(a); if (collection.Count == 0) { return(false); } if (collection.Contains(b.Id)) { return(true); } foreach (IdType aDependency in collection) { if (!NodesToSort.TryGetValue(aDependency, out SortedTreeNode <IdType, DataType> aDep)) { continue; } if (HasSortPreferenceWith(aDep, getCollection, b)) { return(true); } } return(false); }
void CreateTab(string tabname, string lvname, GetItemDelegate gidel,GetCollection gcdel) { if (tabControl1.TabPages.ContainsKey(tabname)) { currentView = (EnhancedListView)tabControl1.Controls[lvname]; } else { if (gidel == null) return; TabPage newTP = new TabPage(tabname); newTP.Name = tabname; currentView = new EnhancedListView(); currentView.FullRowSelect = true; currentView.GridLines = true; currentView.Name = lvname; currentView.TabIndex = 0; currentView.UseCompatibleStateImageBehavior = false; currentView.View = View.Details; currentView.VirtualMode = true; currentView.Dock = DockStyle.Fill; currentView.SetCallback(gidel); currentView.Tag = gcdel; currentView.ContextMenuStrip = contextMenuStrip1; newTP.Controls.Add(currentView); tabControl1.TabPages.Add(newTP); } tabControl1.SelectTab(tabname); }
private void CleanupRedundant(IdType ifThisIsPresent, GetCollection inThisCollection, IdType thenRemoveThis, CleanInternal andPassItAlong) { foreach (SortedTreeNode <IdType, DataType> cleanupNode in NodesToSort.Values) { IList <IdType> collectionToClean = inThisCollection(cleanupNode); if (collectionToClean.Contains(ifThisIsPresent) && collectionToClean.Remove(thenRemoveThis)) { andPassItAlong.Invoke(thenRemoveThis); } } }
public async Task <GetCollection> GetCollectionForEdit(NullableIdDto input) { var output = new GetCollection { }; var Collection = _CollectionRepository .GetAll().Where(p => p.Id == input.Id).FirstOrDefault(); output.Collections = Collection.MapTo <CollectionListDto>(); return(output); }
private void CleanRedundant(GetCollection getCollection, CleanInternal cleanInternal) { Action cleanupActions = null; foreach (SortedTreeNode <IdType, DataType> node in NodesToSort.Values) { IList <IdType> collection = getCollection.Invoke(node); if (collection.Count < 2) { continue; } foreach (IdType d1 in collection) { if (!NodesToSort.TryGetValue(d1, out SortedTreeNode <IdType, DataType> nodeD1)) { continue; } foreach (IdType d2 in collection) { if (d1.Equals(d2)) { continue; } if (!NodesToSort.TryGetValue(d2, out SortedTreeNode <IdType, DataType> nodeD2)) { continue; } if (HasSortPreferenceWith(nodeD1, getCollection, nodeD2)) { // d2 can be removed from entries that already have d1 IdType d3 = d2; cleanupActions += () => CleanupRedundant(d1, getCollection, d3, cleanInternal); } else if (HasSortPreferenceWith(nodeD2, getCollection, nodeD1)) { // d1 can be removed from entries that already have d2 cleanupActions += () => CleanupRedundant(d2, getCollection, d1, cleanInternal); } } } } cleanupActions?.Invoke(); }
internal List <ElementType> /*?*/ Concatenate <ElementType>(GetCollection <ElementType> getCollectionFrom) { Contract.Requires(getCollectionFrom != null); var result = new List <ElementType>(); for (int i = 0, n = this.modulesToMerge.Length; i < n; i++) { var moduleToMerge = this.modulesToMerge[i]; Contract.Assume(moduleToMerge != null); var collection = getCollectionFrom(moduleToMerge); Contract.Assume(collection != null); result.AddRange(collection); } if (result.Count == 0) { return(null); } result.TrimExcess(); return(result); }