public void CollapseDuplicateContexts() { var found = false; for (int i = 0; i < Contexts.Count; i++) { var left = Contexts[i]; for (int j = i + 1; j < Contexts.Count; j++) { var right = Contexts[j]; if (left.Equals(right)) { found = true; foreach (var fact in Facts.Where(f => f.Context.Id == right.Id)) { fact.Context = left; } } } } if (found) { RemoveUnusedContexts(); } }
public void RemoveFact(int id) { if (id == 0) { return; } else { var match = Facts.Where(fact => fact.Id == id).FirstOrDefault(); if (match != null) { Facts.Remove(match); } } }
public void RemoveUnusedContexts() { var usedIds = new HashSet <string>(); var contextIds = Facts. Where(f => f.Context != null). Select(f => f.Context.Id). Concat(FilingIndicators.Select(f => f.ContextRef)). Distinct(). ToList(); usedIds.UnionWith(contextIds); GetUsedContexts(Facts, usedIds); Contexts.RemoveUnusedItems(usedIds); }
/** * @return Returns all facts of the given type. */ public IEnumerable <Fact> GetFacts(string factType) => Facts.Where(f => f.FactType == factType);
/** * @return Returns all facts of the given type. */ public IEnumerable <Fact> GetFacts(string factType) { return(Facts.Where(f => f.FactType == factType)); }