Example #1
0
		private static ComparisonResult Contains(IModelNode tree, IModelNode pattern)
		{
			var deepComparison = tree.Flatten().Select(x => Compare(x, pattern)).AsArray();
			if (deepComparison.Any(x => x.Kind == ComparisonResultKind.Same))
			{
				return new ComparisonResult(ComparisonResultKind.Same, pattern, deepComparison.Where(x => x.Kind == ComparisonResultKind.Same).SelectMany(x => x.Matches).Distinct());
			}

			if (deepComparison.Any(x => x.Kind == ComparisonResultKind.Partial))
			{
				return new ComparisonResult(ComparisonResultKind.Partial, pattern, deepComparison.Where(x => x.Kind == ComparisonResultKind.Partial).SelectMany(x => x.Matches).Distinct());
			}

			return new ComparisonResult(ComparisonResultKind.Different, pattern, null);
		}
Example #2
0
        private static ComparisonResult Contains(IModelNode tree, IModelNode pattern)
        {
            var deepComparison = tree.Flatten().Select(x => Compare(x, pattern)).AsArray();

            if (deepComparison.Any(x => x.Kind == ComparisonResultKind.Same))
            {
                return(new ComparisonResult(ComparisonResultKind.Same, pattern, deepComparison.Where(x => x.Kind == ComparisonResultKind.Same).SelectMany(x => x.Matches).Distinct()));
            }

            if (deepComparison.Any(x => x.Kind == ComparisonResultKind.Partial))
            {
                return(new ComparisonResult(ComparisonResultKind.Partial, pattern, deepComparison.Where(x => x.Kind == ComparisonResultKind.Partial).SelectMany(x => x.Matches).Distinct()));
            }

            return(new ComparisonResult(ComparisonResultKind.Different, pattern, null));
        }