Exemple #1
0
        /// <summary>
        /// <para>从指定的<paramref name="stream"/>反序列化给定类型的值</para>
        /// <para>Deserializes the value of the given type from the specified <paramref name="stream"/></para>
        /// </summary>
        /// <param name="context">反序列化所需要的上下文. The context required for the deserialization </param>
        /// <param name="stream">要进行反序列化的流. The stream to deserialize from</param>
        /// <returns>反序列化的值. The deserialized value</returns>
        public static T Deserialize <T>(ref BssomDeserializeContext context, Stream stream)
        {
            if (TryDeserializeFromMemoryStream <T>(ref context, stream, out T result))
            {
                return(result);
            }

            StreamDeserializeAux aux = new StreamDeserializeAux(stream);

            result = Deserialize <T>(ref context, aux.GetBssomBuffer());
            aux.Dispose();
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// <para>从指定的<paramref name="stream"/>反序列化给定类型的值</para>
        /// <para>Deserializes the value of the given type from the specified <paramref name="stream"/></para>
        /// </summary>
        /// <param name="context">反序列化所需要的上下文. The context required for the deserialization </param>
        /// <param name="stream">反序列化所需要的的缓冲区. The stream to deserialize from</param>
        /// <param name="type">要反序列化的类型. The type to deserialize</param>
        /// <returns>反序列化的值. The deserialized value</returns>
        public static object Deserialize(ref BssomDeserializeContext context, Stream stream, Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (TryDeserializeFromMemoryStream(ref context, stream, type, out object result))
            {
                return(result);
            }

            StreamDeserializeAux aux = new StreamDeserializeAux(stream);

            result = Deserialize(ref context, aux.GetBssomBuffer(), type);
            aux.Dispose();
            return(result);
        }