NArrange.Core.ElementFilter.GetRequiredScope C# (CSharp) Method

GetRequiredScope() private method

Gets the scope required to evaluate the condition.
private GetRequiredScope ( IConditionExpression expression ) : ElementAttributeScope
expression IConditionExpression Condition expression.
return ElementAttributeScope
        private ElementAttributeScope GetRequiredScope(IConditionExpression expression)
        {
            ElementAttributeScope scope = ElementAttributeScope.Element;

            if (expression != null)
            {
                ElementAttributeExpression attributeExpression = expression as ElementAttributeExpression;
                if (attributeExpression != null)
                {
                    scope = attributeExpression.Scope;
                }
                else
                {
                    ElementAttributeScope leftScope = GetRequiredScope(expression.Left);
                    ElementAttributeScope rightScope = GetRequiredScope(expression.Right);

                    if (leftScope > rightScope)
                    {
                        scope = leftScope;
                    }
                    else
                    {
                        scope = rightScope;
                    }
                }
            }

            return scope;
        }