Opc.Ua.ReferenceNode.CompareTo C# (CSharp) Method

CompareTo() public method

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
/// is not the same type as this instance. ///
public CompareTo ( object obj ) : int
obj object An object to compare with this instance.
return int
        public int CompareTo(object obj)
        {
            if (Object.ReferenceEquals(obj, null))
            {
                return +1;
            }

            if (Object.ReferenceEquals(obj, this))
            {
                return 0;
            }

            ReferenceNode reference = obj as ReferenceNode;

            if (reference == null)
            {
                return -1;
            }
            
            if (Object.ReferenceEquals(m_referenceTypeId, null))
            {
                return (Object.ReferenceEquals(reference.m_referenceTypeId, null))?0:-1;
            }

            int result = m_referenceTypeId.CompareTo(reference.m_referenceTypeId);

            if (result != 0)
            {
                return result;           
            }

            if (reference.m_isInverse != this.m_isInverse)
            {
                return (this.m_isInverse)?+1:-1;
            }
            
            if (Object.ReferenceEquals(m_targetId, null))
            {
                return (Object.ReferenceEquals(reference.m_targetId, null))?0:-1;
            }

            return m_targetId.CompareTo(reference.m_targetId);
        }
        #endregion