コード例 #1
0
        private IOrderedEnumerable<IGrouping<string, IGrouping<XElement, ContentPair>>> BuildRemoteOnlyViewModel(Recipe localRecipe, Recipe remoteRecipe)
        {
            var contentTypeComparer = new ContentTypeContentComparer();
            var identifierComparer = new IdentifierContentComparer();
            var layerNameComparer = new LayerNameComparer();

            var comparison = new RecipeComparer().Compare(localRecipe, remoteRecipe,
                            (left, right) => contentTypeComparer.IsMatch(left, right)
                                            && (identifierComparer.IsMatch(left, right) ||
                                            layerNameComparer.IsMatch(left, right)));

            var localonly = comparison.Unmatched
                .Where(pair => pair.Left == null)
                .OrderBy(pair => pair.Right.DisplayLabel())
                .OrderBy(pair => pair.Right.PartType())
                .GroupBy(pair => pair.Right)
                .GroupBy(layer => layer.Key.LayerName())
                .OrderBy(layer => layer.Key);
            return localonly;
        }
コード例 #2
0
        private IOrderedEnumerable<IGrouping<string, IGrouping<XElement, ContentPair>>> BuildMismatchesViewModel(Recipe localRecipe, Recipe remoteRecipe)
        {
            var contentTypeComparer = new ContentTypeContentComparer();
            var identityComparer = new IdentifierContentComparer();
            var layerComparer = new LayerNameComparer();

            var mismatched = new RecipeComparer()
                .Compare(localRecipe, remoteRecipe,
                (left, right) => 
                    contentTypeComparer.IsMatch(left, right) /*&& layerComparer.IsMatch(left,right)*/
                    && (!localRecipe.RecipeSteps.SingleOrDefault(step=>step.Name=="Data").Step.Elements()
                                    .Any(element=>element.Attribute("Id").Value.Equals(right.Attribute("Id").Value, StringComparison.InvariantCulture))
                        ||
                        !remoteRecipe.RecipeSteps.SingleOrDefault(step=>step.Name=="Data").Step.Elements()
                                    .Any(element=>element.Attribute("Id").Value.Equals(left.Attribute("Id").Value, StringComparison.InvariantCulture)))
                    && (_softComparers.Where(comparer => comparer.IsMatch(left, right)).Count() > 1))
                .Matching // all items of same type and title, body or layer name match
                .Where(pair => !identityComparer.IsMatch(pair.Left, pair.Right));
            // where the identifier is different

            var groupedMismatches = mismatched
                .GroupBy(pair => pair.Left)
                .GroupBy(set => set.Key.LayerName())
                .OrderBy(layer => layer.Key);
            return groupedMismatches;
        }