SIPSorcery.SIP.SIPContactHeader.AreEqual C# (CSharp) Method

AreEqual() public static method

Compares two contact headers to determine contact address equality.
public static AreEqual ( SIPContactHeader contact1, SIPContactHeader contact2 ) : bool
contact1 SIPContactHeader
contact2 SIPContactHeader
return bool
        public static bool AreEqual(SIPContactHeader contact1, SIPContactHeader contact2)
        {
            if (!SIPURI.AreEqual(contact1.ContactURI, contact2.ContactURI))
            {
                return false;
            }
            else
            {
                // Compare invaraiant parameters.
                string[] contact1Keys = contact1.ContactParameters.GetKeys();

                if (contact1Keys != null && contact1Keys.Length > 0)
                {
                    foreach (string key in contact1Keys)
                    {
                        if (key == EXPIRES_PARAMETER_KEY || key == QVALUE_PARAMETER_KEY)
                        {
                            continue;
                        }
                        else if (contact1.ContactParameters.Get(key) != contact2.ContactParameters.Get(key))
                        {
                            return false;
                        }
                    }
                }

                // Need to do the reverse as well
                string[] contact2Keys = contact2.ContactParameters.GetKeys();

                if (contact2Keys != null && contact2Keys.Length > 0)
                {
                    foreach (string key in contact2Keys)
                    {
                        if (key == EXPIRES_PARAMETER_KEY || key == QVALUE_PARAMETER_KEY)
                        {
                            continue;
                        }
                        else if (contact2.ContactParameters.Get(key) != contact1.ContactParameters.Get(key))
                        {
                            return false;
                        }
                    }
                }
            }

            return true;
        }