Did some inline implementations

This commit is contained in:
Serraniel 2018-04-06 17:45:53 +02:00
parent c419fa2757
commit 18107c64c7
2 changed files with 16 additions and 7 deletions

View file

@ -1,4 +1,5 @@
using System.IO; using System;
using System.IO;
using SweetLib.Classes.Storer; using SweetLib.Classes.Storer;
using SweetLib.IO.Classes.Streaming; using SweetLib.IO.Classes.Streaming;
using SweetLib.Utils.Logger; using SweetLib.Utils.Logger;
@ -26,13 +27,22 @@ namespace SweetLib.Demo.Console
using (var stream = File.Create(@"S:\test.dat")) using (var stream = File.Create(@"S:\test.dat"))
{ {
StreamManager.SaveToStream(stream, 5); StreamManager.SaveToStream(stream, 5);
StreamManager.SaveToStream(stream, "Hallo Wellt eksde");
StreamManager.SaveToStream(stream, 12d);
StreamManager.SaveToStream(stream, DateTime.UtcNow);
} }
using (var stream = File.OpenRead(@"S:\test.dat")) using (var stream = File.OpenRead(@"S:\test.dat"))
{ {
int value; StreamManager.LoadFromStream(stream, out int iValue);
StreamManager.LoadFromStream(stream, out value); StreamManager.LoadFromStream(stream, out string sValue);
System.Console.WriteLine(value); StreamManager.LoadFromStream(stream, out double dValue);
StreamManager.LoadFromStream(stream, out DateTime dtValue);
System.Console.WriteLine(iValue);
System.Console.WriteLine(sValue);
System.Console.WriteLine(dValue);
System.Console.WriteLine(dtValue);
} }
System.Console.ReadLine(); System.Console.ReadLine();

View file

@ -55,10 +55,9 @@ namespace SweetLib.IO.Classes.Streaming
private static byte[] LoadFromStream(Stream stream, StreamedObjectType type) private static byte[] LoadFromStream(Stream stream, StreamedObjectType type)
{ {
StreamedObjectType foundType;
long length; long length;
LoadMetaDataFromStream(stream, out foundType, out length); LoadMetaDataFromStream(stream, out StreamedObjectType foundType, out length);
if (foundType != type) if (foundType != type)
throw new StreamTypeException($"Expected {type} but found {foundType} instead."); throw new StreamTypeException($"Expected {type} but found {foundType} instead.");