internal void OnSerializingMethod(StreamingContext context) { ComputeChecksum(); if (IsDeltaSource) { // Do not save identities that are present in the baseline IdentityAndIndexList = IndexToIdentity.Where(p => !IsInBaseline(p.Key)).ToList(); for (int i = 0; i <= BaselineIndexesEnd; i++) { UpdateAndProductIndex.Remove(i); UpdateAndClassificationIndex.Remove(i); } foreach (var typeEntry in BaselineSource.UpdateTypeMap) { if (UpdateTypeMap.ContainsKey(typeEntry.Key)) { UpdateTypeMap.Remove(typeEntry.Key); } } } else { IdentityAndIndexList = IndexToIdentity.ToList(); } }
private bool HasProduct(int updateIndex) { EnsureProductClassificationIndexLoaded(); if (UpdateAndProductIndex.ContainsKey(updateIndex)) { return(true); } else if (IsInBaseline(updateIndex)) { return(BaselineSource.HasProduct(updateIndex)); } else { return(false); } }
private List <Guid> GetUpdateProductIds(int updateIndex) { EnsureProductClassificationIndexLoaded(); if (UpdateAndProductIndex.ContainsKey(updateIndex)) { return(UpdateAndProductIndex[updateIndex]); } else if (IsInBaseline(updateIndex)) { return(BaselineSource.GetUpdateProductIds(updateIndex)); } else { throw new Exception($"Update {this[updateIndex]} does not have product information"); } }
private void ResolveProductsAndClassifications() { var progress = new OperationProgress() { CurrentOperation = OperationType.IndexingCategoriesProgress, Maximum = AddedUpdates.Count }; var productsList = Categories.Values.OfType <Product>().Select(p => p.Identity).ToList(); var classificationsList = Categories.Values.OfType <Classification>().Select(c => c.Identity).ToHashSet(); // Fill in product and classification information. foreach (var updateEntry in AddedUpdates) { if (AddedPrerequisites.ContainsKey(updateEntry.Value.Identity)) { // Find product information and add it to the index var updateProductsList = CategoryResolver.ResolveProductFromPrerequisites(AddedPrerequisites[updateEntry.Value.Identity], productsList); if (updateProductsList.Count > 0) { UpdateAndProductIndex.Add(updateEntry.Key, updateProductsList); } // Find classification information and add it to the index var updateClassificationsList = CategoryResolver.ResolveClassificationFromPrerequisites(AddedPrerequisites[updateEntry.Value.Identity], classificationsList); if (updateClassificationsList.Count > 0) { UpdateAndClassificationIndex.Add(updateEntry.Key, updateClassificationsList); } } progress.Current++; if (progress.Current % 1000 == 0) { CommitProgress?.Invoke(this, progress); } } }