Skip to content

Commit

Permalink
Command Line Version
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-dolkens committed Feb 24, 2016
1 parent 54ea414 commit 2752d26
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 31 deletions.
30 changes: 14 additions & 16 deletions HoloXPLOR.DataForge/DataForge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace HoloXPLOR.DataForge
{
public static class DataForgeSerializer
{
public static TObject Deserialize<TObject>(String inFile) where TObject : class
public static XmlDocument ReadFile(String inFile)
{
using (BinaryReader br = new BinaryReader(File.OpenRead(inFile)))
{
Expand Down Expand Up @@ -156,25 +156,23 @@ public static TObject Deserialize<TObject>(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<TObject>(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;
}
}
}
Expand Down
15 changes: 5 additions & 10 deletions HoloXPLOR.DataForge/HoloXPLOR.DataForge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A8EDECDB-B8B6-437B-9381-8AA02139B7E0}</ProjectGuid>
<OutputType>Library</OutputType>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HoloXPLOR.DataForge</RootNamespace>
<AssemblyName>HoloXPLOR.DataForge</AssemblyName>
Expand Down Expand Up @@ -35,15 +35,10 @@
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dolkens.Framework, Version=1.0.5648.17179, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dolkens.Framework.1.0.5648.17179\lib\net45\Dolkens.Framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -60,11 +55,11 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="DataForge.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
26 changes: 26 additions & 0 deletions HoloXPLOR.DataForge/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HoloXPLOR.DataForge
{
public static class Program
{
public static void Main(params String[] args)
{
if (args.Length != 1)
{
Console.WriteLine("Usage: HoloXPLOR.DataForge.exe [infile]");
Console.WriteLine();
Console.WriteLine("Converts an SC binary `xml` file into an actual XML file, and saves it as a .raw file in the original location");
return;
}

var xml = DataForgeSerializer.ReadFile(args[0]);
xml.Save(Path.ChangeExtension(args[0], "raw"));
}
}
}
5 changes: 0 additions & 5 deletions HoloXPLOR.DataForge/packages.config

This file was deleted.

0 comments on commit 2752d26

Please sign in to comment.