コード例 #1
0
        /// <summary>
        /// Deserializes an object from a KeyValues representation in a stream.
        /// </summary>
        /// <param name="stream">The stream to deserialize from.</param>
        /// <param name="options">Options to use that can influence the deserialization process.</param>
        /// <returns>A <typeparamref name="TObject" /> instance representing the KeyValues structure in the stream.</returns>
        /// <typeparam name="TObject">The type of object to deserialize.</typeparam>;
        public TObject Deserialize <TObject>(Stream stream, KvSerializerOptions options = null)
        {
            Require.NotNull(stream, nameof(stream));

            var @object     = Deserialize(stream, options ?? KvSerializerOptions.DefaultOptions);
            var typedObject = ObjectCopier.MakeObject <TObject>(@object);

            return(typedObject);
        }
コード例 #2
0
ファイル: KVSerializer.cs プロジェクト: xfw5/ValveKeyValue
        /// <summary>
        /// Deserializes an object from a textual KeyValues representation.
        /// </summary>
        /// <param name="text">The text to deserialize.</param>
        /// <param name="options">Options to use that can influence the deserialization process.</param>
        /// <returns>A <see cref="KVObject"/> representing the KeyValues structure in the stream.</returns>
        /// <returns>A <typeparamref name="TObject" /> instance representing the KeyValues structure in the stream.</returns>
        /// <typeparam name="TObject">The type of object to deserialize.</typeparam>;
        public static TObject Deserialize <TObject>(string text, KVSerializerOptions options = null)
        {
            Require.NotNull(text, nameof(text));

            var @object     = Deserialize(text, options ?? KVSerializerOptions.DefaultOptions);
            var typedObject = ObjectCopier.MakeObject <TObject>(@object);

            return(typedObject);
        }