Fixed issue #107. The code for it was mostly already written.
This commit is contained in:
parent
4a948b9098
commit
48f93e6f0d
@ -19,16 +19,19 @@ public static class VkvConvert
|
||||
|
||||
#region DeserializeNode
|
||||
public static VkvNode? DeserializeNode(StreamReader reader) =>
|
||||
DeserializeNode(reader, VkvOptions.Default);
|
||||
public static VkvNode? DeserializeNode(StreamReader reader, VkvOptions options)
|
||||
DeserializeNode(reader, VkvOptions.Default, out _);
|
||||
public static VkvNode? DeserializeNode(StreamReader reader, VkvOptions options) =>
|
||||
DeserializeNode(reader, options, out _);
|
||||
public static VkvNode? DeserializeNode(StreamReader reader, VkvOptions options, out string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return DeserializeNode(reader, options, out _, null);
|
||||
return DeserializeNode(reader, options, out name, null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (!options.noExceptions) throw;
|
||||
name = string.Empty;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,6 +29,23 @@ public class VkvSerializer
|
||||
if (!p_options.closeWhenFinished && p_options.resetStreamPosition) stream.Seek(pos, SeekOrigin.Begin);
|
||||
}
|
||||
}
|
||||
public VkvNode? Deserialize(Stream stream, out string name)
|
||||
{
|
||||
long pos = stream.Position;
|
||||
StreamReader reader = new(stream, leaveOpen: !p_options.closeWhenFinished);
|
||||
try
|
||||
{
|
||||
VkvNode? result = VkvConvert.DeserializeNode(reader, p_options, out name);
|
||||
reader.Close();
|
||||
if (!p_options.closeWhenFinished && p_options.resetStreamPosition) stream.Seek(pos, SeekOrigin.Begin);
|
||||
return result;
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.Close();
|
||||
if (!p_options.closeWhenFinished && p_options.resetStreamPosition) stream.Seek(pos, SeekOrigin.Begin);
|
||||
}
|
||||
}
|
||||
public T? Deserialize<T>(Stream stream)
|
||||
{
|
||||
VkvNode? result = Deserialize(stream);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user