diff --git a/SweetLib.Demo.Console/Program.cs b/SweetLib.Demo.Console/Program.cs index b865291..a5976f5 100644 --- a/SweetLib.Demo.Console/Program.cs +++ b/SweetLib.Demo.Console/Program.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using SweetLib.Classes.Storer; using SweetLib.IO.Classes.Streaming; using SweetLib.Utils.Logger; @@ -26,13 +27,22 @@ namespace SweetLib.Demo.Console using (var stream = File.Create(@"S:\test.dat")) { 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")) { - int value; - StreamManager.LoadFromStream(stream, out value); - System.Console.WriteLine(value); + StreamManager.LoadFromStream(stream, out int iValue); + StreamManager.LoadFromStream(stream, out string sValue); + 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(); diff --git a/SweetLib.IO/Classes/Streaming/StreamManager.cs b/SweetLib.IO/Classes/Streaming/StreamManager.cs index a230919..f539491 100644 --- a/SweetLib.IO/Classes/Streaming/StreamManager.cs +++ b/SweetLib.IO/Classes/Streaming/StreamManager.cs @@ -55,10 +55,9 @@ namespace SweetLib.IO.Classes.Streaming private static byte[] LoadFromStream(Stream stream, StreamedObjectType type) { - StreamedObjectType foundType; long length; - LoadMetaDataFromStream(stream, out foundType, out length); + LoadMetaDataFromStream(stream, out StreamedObjectType foundType, out length); if (foundType != type) throw new StreamTypeException($"Expected {type} but found {foundType} instead."); @@ -68,7 +67,7 @@ namespace SweetLib.IO.Classes.Streaming return buffer; } - + public static void SaveToStream(Stream stream, string value) { SaveToStream(stream, StreamedObjectType.StringValue, value.AsBytes());