Opc.Ua.ContentFilter.And C# (CSharp) Method

And() private method

And FilterOperator
private And ( FilterContext context, IFilterTarget target, ContentFilterElement element ) : bool?
context FilterContext
target IFilterTarget
element ContentFilterElement
return bool?
        private bool? And(FilterContext context, IFilterTarget target, ContentFilterElement element)
        {
            FilterOperand[] operands = GetOperands(element, 2);

            bool? lhs = GetValue(context, operands[0], target) as bool?;

            // no need for further processing if first operand is false.
            if (lhs != null && !lhs.Value)
            {
                return false;
            }

            bool? rhs = GetValue(context, operands[1], target) as bool?;
            
            if (lhs == null)
            {
                if (rhs == null || rhs == true)
                {
                    return null;
                }
                else
                {
                    return false;
                }
            }
            
            if (rhs == null)
            {
                if (lhs == null || lhs == true)
                {
                    return null;
                }
                else
                {
                    return false;
                }
            }

            return lhs.Value && rhs.Value;
        }