Пример #1
0
 internal uint GetUniformHashCode()
 {
     // Disabling this ReSharper warning; hashCache is a logically read-only variable, so accessing them in GetHashCode is safe.
     // ReSharper disable NonReadonlyFieldInGetHashCode
     if (uniformHashCache == 0)
     {
         JenkinsHash jenkinsHash = JenkinsHash.Factory.GetHashGenerator();
         uint        n;
         if (HasKeyExt && KeyExt != null)
         {
             var writer = new BinaryTokenStreamWriter();
             writer.Write(this);
             byte[] bytes = writer.ToByteArray();
             writer.ReleaseBuffers();
             n = jenkinsHash.ComputeHash(bytes);
         }
         else
         {
             n = jenkinsHash.ComputeHash(TypeCodeData, N0, N1);
         }
         // Unchecked is required because the Jenkins hash is an unsigned 32-bit integer,
         // which we need to convert to a signed 32-bit integer.
         uniformHashCache = n;
     }
     return(uniformHashCache);
     // ReSharper restore NonReadonlyFieldInGetHashCode
 }
Пример #2
0
 private static byte[] GetTokenBytes(SerializationManager serializationManager, StreamSequenceToken token)
 {
     var bodyStream = new BinaryTokenStreamWriter();
     serializationManager.Serialize(token, bodyStream);
     var result = bodyStream.ToByteArray();
     bodyStream.ReleaseBuffers();
     return result;
 }
Пример #3
0
        /// <summary>
        /// Serializes event data properties
        /// </summary>
        /// <param name="eventData"></param>
        /// <param name="serializationManager"></param>
        /// <returns></returns>
        public static byte[] SerializeProperties(this EventData eventData, SerializationManager serializationManager)
        {
            var writeStream = new BinaryTokenStreamWriter();

            serializationManager.Serialize(eventData.Properties.Where(kvp => !string.Equals(kvp.Key, EventDataPropertyStreamNamespaceKey, StringComparison.Ordinal)).ToList(), writeStream);
            var result = writeStream.ToByteArray();

            writeStream.ReleaseBuffers();
            return(result);
        }
Пример #4
0
        public int Orleans()
        {
            var orleansBuffer = new BinaryTokenStreamWriter();

            OrleansSerializer.Serialize(Input, orleansBuffer);
            var result = orleansBuffer.CurrentOffset;

            orleansBuffer.ReleaseBuffers();
            return(result);
        }
Пример #5
0
        /// <summary>
        /// Serializes event data properties
        /// </summary>
        /// <param name="eventData"></param>
        /// <returns></returns>
        public static byte[] SerializeProperties(this EventData eventData)
        {
            var writeStream = new BinaryTokenStreamWriter();

            SerializationManager.Serialize(eventData.Properties.Where(kvp => !SkipProperties.Contains(kvp.Key)).ToList(), writeStream);
            var result = writeStream.ToByteArray();

            writeStream.ReleaseBuffers();
            return(result);
        }
Пример #6
0
        internal byte[] ToByteArray()
        {
            var writer = new BinaryTokenStreamWriter();

            writer.Write(this);
            var result = writer.ToByteArray();

            writer.ReleaseBuffers();
            return(result);
        }
Пример #7
0
        public static byte[] ToByteArray(this GrainId @this)
        {
            var writer = new BinaryTokenStreamWriter();

            writer.Write(@this);
            var result = writer.ToByteArray();

            writer.ReleaseBuffers();
            return(result);
        }
Пример #8
0
        private uint GetUniformHashCode(JenkinsHash jenkinsHash, int extraBit)
        {
            var writer = new BinaryTokenStreamWriter();

            writer.Write(this);
            writer.Write(extraBit);
            byte[] bytes = writer.ToByteArray();
            writer.ReleaseBuffers();
            return(jenkinsHash.ComputeHash(bytes));
        }