예제 #1
0
        int GetHashCodeInternal(bool ignoreMessageTime)
        {
            // The primary source of the hash is message's position. But it is not the only source,
            // we have to use the other fields because messages might be at the same position
            // but be different. That might happen, for example, when a message was at the end
            // of the live stream and wasn't read completely. As the stream grows the same message
            // will be fully written and might be eventually read again.
            // Those two message might be different, thought they are at the same position.

            int ret = Hashing.GetStableHashCode(position);

            ret ^= text.GetStableHashCode();

            if (!ignoreMessageTime)
            {
                ret = MessagesUtils.XORTimestampHash(ret, time);
            }
            if (thread != null)
            {
                ret ^= Hashing.GetStableHashCode(thread.ID);
            }
            ret ^= (int)(flags & MessageFlag.ContentTypeMask);

            return(ret);
        }
예제 #2
0
        int GetHashCodeInternal(bool ignoreMessageTime)
        {
            // The primary source of the hash is message's position. But it is not the only source,
            // we have to use the other fields because messages might be at the same position
            // but be different. That might happen, for example, when a message was at the end
            // of the live stream and wasn't read completely. As the stream grows the same message
            // will be fully written and might be eventually read again.
            // Those two message might be different, thought they are at the same position.

            int ret = Hashing.GetStableHashCode(position);

            // Don't hash Text for frame-end beacause it doesn't have its own permanent text.
            // It takes the text from brame begin instead. The link to frame begin may change
            // during the time (it may get null or not null).
            if ((flags & MessageFlag.TypeMask) != MessageFlag.EndFrame)
            {
                ret ^= DoGetText().GetStableHashCode();
            }

            if (!ignoreMessageTime)
            {
                ret = MessagesUtils.XORTimestampHash(ret, time);
            }
            if (thread != null)
            {
                ret ^= Hashing.GetStableHashCode(thread.ID);
            }
            ret ^= (int)(flags & (MessageFlag.TypeMask | MessageFlag.ContentTypeMask));

            return(ret);
        }
예제 #3
0
        public override int GetHashCode()
        {
#if !SILVERLIGHT
            return(Hashing.GetStableHashCode(str, index, length));
#else
            return(Value.GetHashCode());
#endif
        }
        int IPositionedMessagesReader.GetContentsEtag()
        {
            VolatileStream.Position = 0;
            byte[] buf  = new byte[1024];
            int    read = VolatileStream.Read(buf, 0, buf.Length);

            return(Hashing.GetStableHashCode(buf, 0, read));
        }
예제 #5
0
        async ValueTask <int> IPositionedMessagesReader.GetContentsEtag()
        {
            VolatileStream.Position = 0;
            byte[] buf  = new byte[1024];
            int    read = await VolatileStream.ReadAsync(buf, 0, buf.Length);

            return(Hashing.GetStableHashCode(buf, 0, read));
        }
예제 #6
0
 public int GetStableHashCode()
 {
     if (data.Kind == DateTimeKind.Unspecified)
     {
         return(Hashing.GetStableHashCode(new DateTime(data.Ticks, DateTimeKind.Local)));
     }
     return(Hashing.GetStableHashCode(data));
 }
예제 #7
0
 public int GetStableHashCode()
 {
     return(Hashing.GetStableHashCode(str, index, length));
 }