From 2752d2689843aa5c49f1c37ae5d98862cc2801cc Mon Sep 17 00:00:00 2001 From: Peter Dolkens Date: Wed, 24 Feb 2016 00:28:53 +0000 Subject: [PATCH] Command Line Version --- HoloXPLOR.DataForge/DataForge.cs | 30 +++++++++---------- .../HoloXPLOR.DataForge.csproj | 15 ++++------ HoloXPLOR.DataForge/Program.cs | 26 ++++++++++++++++ HoloXPLOR.DataForge/packages.config | 5 ---- 4 files changed, 45 insertions(+), 31 deletions(-) create mode 100644 HoloXPLOR.DataForge/Program.cs delete mode 100644 HoloXPLOR.DataForge/packages.config diff --git a/HoloXPLOR.DataForge/DataForge.cs b/HoloXPLOR.DataForge/DataForge.cs index 1dc8236..2379152 100644 --- a/HoloXPLOR.DataForge/DataForge.cs +++ b/HoloXPLOR.DataForge/DataForge.cs @@ -14,7 +14,7 @@ namespace HoloXPLOR.DataForge { public static class DataForgeSerializer { - public static TObject Deserialize(String inFile) where TObject : class + public static XmlDocument ReadFile(String inFile) { using (BinaryReader br = new BinaryReader(File.OpenRead(inFile))) { @@ -156,25 +156,23 @@ public static TObject Deserialize(String inFile) where TObject : class xmlDoc.AppendChild(element); } - using (MemoryStream ms = new MemoryStream()) - { - // if (bugged) - // { - // xmlDoc.Save(Path.ChangeExtension(inFile, "bug")); - // } - // else - // { - // xmlDoc.Save(Path.ChangeExtension(inFile, "raw")); - // } + return xmlDoc; + } + } - xmlDoc.Save(ms); + public static TObject Deserialize(String inFile) where TObject : class + { + using (MemoryStream ms = new MemoryStream()) + { + var xmlDoc = DataForgeSerializer.ReadFile(inFile); - ms.Seek(0, SeekOrigin.Begin); + xmlDoc.Save(ms); - XmlSerializer xs = new XmlSerializer(typeof(TObject)); + ms.Seek(0, SeekOrigin.Begin); - return xs.Deserialize(ms) as TObject; - } + XmlSerializer xs = new XmlSerializer(typeof(TObject)); + + return xs.Deserialize(ms) as TObject; } } } diff --git a/HoloXPLOR.DataForge/HoloXPLOR.DataForge.csproj b/HoloXPLOR.DataForge/HoloXPLOR.DataForge.csproj index fe9e809..c8828e9 100644 --- a/HoloXPLOR.DataForge/HoloXPLOR.DataForge.csproj +++ b/HoloXPLOR.DataForge/HoloXPLOR.DataForge.csproj @@ -5,7 +5,7 @@ Debug AnyCPU {A8EDECDB-B8B6-437B-9381-8AA02139B7E0} - Library + Exe Properties HoloXPLOR.DataForge HoloXPLOR.DataForge @@ -35,15 +35,10 @@ + + true + - - ..\packages\Dolkens.Framework.1.0.5648.17179\lib\net45\Dolkens.Framework.dll - True - - - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - True - @@ -60,11 +55,11 @@ Code + -