Example #1
0
 public static byte[] SerializeXIdentity(this XIdentity xIdentity)
 {
     byte[] serialized = PocoSerializer.Begin()
                         .Append(xIdentity.Id)
                         .Append(xIdentity.PublicIdentityKey)
                         .Append(xIdentity.FirstSeenUTC)
                         .Append(xIdentity.LastSeenUTC)
                         .Append((byte)xIdentity.ContactState)
                         .Finish();
     return(serialized);
 }
Example #2
0
        public static XIdentity DeserializeXIdentityCore(this byte[] messagePart)
        {
            var xIdentity = new XIdentity();

            var ser = PocoSerializer.GetDeserializer(messagePart);

            xIdentity.Id = ser.MakeString(0);
            xIdentity.PublicIdentityKey = ser.MakeByteArray(1);
            xIdentity.FirstSeenUTC      = ser.MakeDateTime(2);
            xIdentity.LastSeenUTC       = ser.MakeDateTime(3);
            xIdentity.ContactState      = (ContactState)ser.MakeByte(4);

            return(xIdentity);
        }
Example #3
0
        public static bool EqualDeep(this XIdentity id1, XIdentity id2)
        {
            if (ReferenceEquals(id1, id2))
            {
                return(true);
            }

            if (id1 == null || id2 == null)
            {
                return(false);
            }

            if (id1.Id != id2.Id)
            {
                return(false);
            }

            if (!ByteArrays.AreAllBytesEqualOrBothNull(id1.PublicIdentityKey, id2.PublicIdentityKey))
            {
                return(false);
            }

            return(true);
        }
Example #4
0
 public bool Equals(XIdentity p)
 {
     return(p != null && p.EqualDeep(this));
 }
Example #5
0
        public override bool Equals(object obj)
        {
            XIdentity p = obj as XIdentity;

            return(p != null && p.EqualDeep(this));
        }