Opc.Ua.ContentFilterElement.ToString C# (CSharp) Method

ToString() public method

Converts an ContentFilterElement to a displayable string.
public ToString ( INodeTable nodeTable ) : string
nodeTable INodeTable The node table.
return string
        public virtual string ToString(INodeTable nodeTable)
        {
            List<FilterOperand> operands = GetOperands();

            string operand1 = (operands.Count > 0)?operands[0].ToString(nodeTable):null;
            string operand2 = (operands.Count > 1)?operands[1].ToString(nodeTable):null;
            string operand3 = (operands.Count > 2)?operands[2].ToString(nodeTable):null;

            StringBuilder buffer = new StringBuilder();

            switch (FilterOperator)
            {
                case FilterOperator.OfType:
                case FilterOperator.InView:
                case FilterOperator.IsNull:
                case FilterOperator.Not:
                {
                    buffer.AppendFormat("{0} '{1}'", FilterOperator, operand1);
                    break;
                }
                    
                case FilterOperator.And:
                case FilterOperator.Equals:
                case FilterOperator.GreaterThan:
                case FilterOperator.GreaterThanOrEqual:
                case FilterOperator.LessThan:
                case FilterOperator.LessThanOrEqual:
                case FilterOperator.Like:
                case FilterOperator.Or:
                {
                    buffer.AppendFormat("'{1}' {0} '{2}'", FilterOperator, operand1, operand2);
                    break;
                }
                    
                case FilterOperator.Between:
                {
                    buffer.AppendFormat("'{1}' <= '{0}' <= '{2}'", operand1, operand2, operand3);
                    break;
                }
                    
                case FilterOperator.Cast:
                {
                    buffer.AppendFormat("({1}){0}", operand1, operand2);
                    break;
                }
                    
                case FilterOperator.InList:
                {
                    buffer.AppendFormat("'{0}' in {", operand1);

                    for (int ii = 1; ii < operands.Count; ii++)
                    {
                        if (ii < operands.Count-1)
                        {
                            buffer.Append(", ");
                        }

                        buffer.AppendFormat("'{0}'", operands[ii].ToString());
                    }
                            
                    buffer.Append("}");
                    break;
                }
                    
                case FilterOperator.RelatedTo:
                {
                    buffer.AppendFormat("'{0}' ", operand1);
                    
                    string referenceType = operand2;

                    if (operands.Count > 1)
                    {
                        LiteralOperand literalOperand = operands[1] as LiteralOperand;

                        if (literalOperand != null)
                        {
                            INode node = nodeTable.Find(literalOperand.Value.Value as NodeId);

                            if (node != null)
                            {
                                referenceType = Utils.Format("{0}", node);
                            }
                        }
                    }
                    
                    buffer.AppendFormat("{0} '{1}'", referenceType, operand2);

                    if (operand3 != null)
                    {
                        buffer.AppendFormat("Hops='{0}'", operand3);
                    }

                    break;
                }
            }

            return buffer.ToString();
        }
        #endregion

Same methods

ContentFilterElement::ToString ( ) : string
ContentFilterElement::ToString ( string format, IFormatProvider formatProvider ) : string