Example #1
0
        /// <summary>Deserialize a patch info</summary>
        /// <param name="bytes">The byte array</param>
        /// <returns>A patch info</returns>
        ///
        internal static PatchInfo Deserialize(byte[] bytes)
        {
            var surrogateSelector = PatchSurrogate.GetSelector();
            var formatter         = new BinaryFormatter {
                SurrogateSelector = surrogateSelector, Binder = new Binder()
            };

#pragma warning disable XS0001
            var streamMemory = new MemoryStream(bytes);
#pragma warning restore XS0001
            return((PatchInfo)formatter.Deserialize(streamMemory));
        }
Example #2
0
        /// <summary>Serializes a patch info</summary>
        /// <param name="patchInfo">The patch info</param>
        /// <returns>A byte array</returns>
        ///
        internal static byte[] Serialize(this PatchInfo patchInfo)
        {
#pragma warning disable XS0001
            using (var streamMemory = new MemoryStream())
            {
                var surrogateSelector = PatchSurrogate.GetSelector();
                var formatter         = new BinaryFormatter()
                {
                    SurrogateSelector = surrogateSelector
                };
                formatter.Serialize(streamMemory, patchInfo);
                return(streamMemory.GetBuffer());
            }
#pragma warning restore XS0001
        }