System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.UnifySpanMappings C# (CSharp) Method

UnifySpanMappings() private method

Unifies the Span information from the specified left and right expressions, and applies it to the specified to expression. Unification proceeds as follows: - If neither left nor right have Span information, no changes are made - If one of left or right has Span information, that single Span information entry is removed from the Span mapping dictionary and used to create a new entry that maps from the expression to the Span information. - If both left and right have Span information, both entries are removed from the Span mapping dictionary, a new Span is created that contains the union of the original Spans, and a new entry is added to the dictionary that maps from to expression to this new Span.
private UnifySpanMappings ( DbExpression left, DbExpression right, DbExpression to ) : void
left DbExpression The first expression argument
right DbExpression The second expression argument
to DbExpression The result expression
return void
        private void UnifySpanMappings(DbExpression left, DbExpression right, DbExpression to)
        {
            Span leftSpan = null;
            Span rightSpan = null;

            var hasLeftSpan = TryGetSpan(left, out leftSpan);
            var hasRightSpan = TryGetSpan(right, out rightSpan);
            if (!hasLeftSpan
                && !hasRightSpan)
            {
                return;
            }

            Debug.Assert(leftSpan != null || rightSpan != null, "Span mappings contain null?");
            AddSpanMapping(to, Span.CopyUnion(leftSpan, rightSpan));
        }