コード例 #1
0
ファイル: EventDataExtensions.cs プロジェクト: jdom/orleans
 /// <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;
 }
コード例 #2
0
        /// <summary>
        /// Creates a deep copy of an object
        /// </summary>
        /// <param name="source">The source object to be copy</param>
        /// <returns>The copy that was created</returns>
        public object DeepCopy(object source)
        {
            if (source == null)
            {
                return(null);
            }

            var writer = new BinaryTokenStreamWriter();

            Serialize(source, writer, source.GetType());
            var retVal = Deserialize(source.GetType(), new BinaryTokenStreamReader(writer.ToByteArray()));

            writer.ReleaseBuffers();
            return(retVal);
        }
コード例 #3
0
        /// <inheritdoc />
        public object DeepCopy(object source, ICopyContext context)
        {
            if (source == null)
            {
                return null;
            }

            var outputWriter = new BinaryTokenStreamWriter();
            var serializationContext = new SerializationContext(context.GetSerializationManager())
            {
                StreamWriter = outputWriter
            };

            Serialize(source, serializationContext, source.GetType());
            var deserializationContext = new DeserializationContext(context.GetSerializationManager())
            {
                StreamReader = new BinaryTokenStreamReader(outputWriter.ToBytes())
            };

            var retVal = Deserialize(source.GetType(), deserializationContext);
            outputWriter.ReleaseBuffers();
            return retVal;
        }
コード例 #4
0
 private static byte[] GetTokenBytes(StreamSequenceToken token)
 {
     var bodyStream = new BinaryTokenStreamWriter();
     SerializationManager.Serialize(token, bodyStream);
     var result = bodyStream.ToByteArray();
     bodyStream.ReleaseBuffers();
     return result;
 }
コード例 #5
0
ファイル: OrleansJsonSerializer.cs プロジェクト: jdom/orleans
        /// <summary>
        /// Creates a deep copy of an object
        /// </summary>
        /// <param name="source">The source object to be copy</param>
        /// <returns>The copy that was created</returns>
        public object DeepCopy(object source)
        {
            if (source == null)
            {
                return null;
            }

            var writer = new BinaryTokenStreamWriter();
            Serialize(source, writer, source.GetType());
            var retVal = Deserialize(source.GetType(), new BinaryTokenStreamReader(writer.ToByteArray()));
            writer.ReleaseBuffers();
            return retVal;
        }