Ejemplo n.º 1
0
        private HessianSerializationScheme GetSerializationScheme()
        {
            if (null == scheme)
            {
                var factory = new HessianObjectSerializerFactory();
                scheme = HessianSerializationScheme.CreateFromMethod(methodInfo, factory);
            }

            return(scheme);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        public object ReadObject(Stream stream)
        {
            if (null == stream)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            var factory = new HessianObjectSerializerFactory();
            var scheme  = HessianSerializationScheme.CreateFromType(type, factory);

            using (var reader = new HessianInputReader(stream))
            {
                var context = new HessianSerializationContext();
                return(scheme.Deserialize(reader, context));
            }
        }
        /// <summary>
        /// Serializes a specified object to binary data and writes the resulting to a stream.
        /// </summary>
        /// <param name="stream">The <see cref="System.IO.Stream" /> that is written to.</param>
        /// <param name="graph">The object that contains the data to write to the stream.</param>
        public void WriteObject(Stream stream, object graph)
        {
            if (null == stream)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            var factory = new HessianObjectSerializerFactory();
            var scheme  = HessianSerializationScheme.CreateFromType(type, factory);

            using (var writer = new HessianOutputWriter(stream))
            {
                var context = new HessianSerializationContext();
                scheme.Serialize(writer, graph, context);
            }
        }