Create and implement IGenerate, IImport

This commit is contained in:
Matt Nadareski
2016-05-28 16:15:47 -07:00
parent 7a5826e64b
commit 07db29cfbf
9 changed files with 29 additions and 15 deletions

View File

@@ -11,7 +11,7 @@ namespace SabreTools
/// <summary>
/// Entry class for the DATabase application
/// </summary>
class DATabase
public class DATabase
{
private static Logger logger;
private static string _dbName = "DATabase.sqlite";
@@ -1298,7 +1298,7 @@ Make a selection:
if (filename != "" && File.Exists(filename))
{
logger.User("Beginning import of " + filename);
Import imp = new Import(filename, _connectionString, logger);
IImport imp = new Import(filename, _connectionString, logger);
bool success = imp.ImportData();
logger.User(filename + (success ? "" : " not") + " imported!");
}
@@ -1308,7 +1308,7 @@ Make a selection:
foreach (string file in Directory.GetFiles(filename, "*", SearchOption.AllDirectories))
{
logger.User("Beginning import of " + file);
Import imp = new Import(file, _connectionString, logger);
IImport imp = new Import(file, _connectionString, logger);
bool success = imp.ImportData();
logger.User(file + (success ? "" : " not") + " imported!");
}
@@ -1329,7 +1329,7 @@ Make a selection:
/// <param name="old">True if the output file should be in ClrMamePro format (default false)</param>
private static void InitGenerate(string systems, string sources, string outdir, bool norename, bool old)
{
Generate gen = new Generate(systems, sources, outdir, _connectionString, logger, norename, old);
IGenerate gen = new Generate(systems, sources, outdir, _connectionString, logger, norename, old);
gen.Export();
return;
}

View File

@@ -11,7 +11,7 @@ namespace SabreTools
/// <summary>
/// Generate a DAT from the data in the database
/// </summary>
class Generate
class Generate : IGenerate
{
// Private instance variables
private string _systems;

View File

@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using Mono.Data.Sqlite;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml;
using SabreTools.Helper;
@@ -12,7 +10,7 @@ namespace SabreTools
/// <summary>
/// Import data into the database from existing DATs
/// </summary>
public class Import
public class Import : IImport
{
// Private instance variables
private string _filepath;

View File

@@ -77,8 +77,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="DATabaseTwo.cs" />
<Compile Include="Generate.cs" />
<Compile Include="Import.cs" />
<Compile Include="GenerateTwo.cs" />
<Compile Include="ImportTwo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

View File

@@ -10,7 +10,7 @@ using SabreTools.Helper;
namespace SabreTools
{
public class Generate
public class GenerateTwo : IGenerate
{
// Private instance variables
private string _systemid;
@@ -35,7 +35,7 @@ namespace SabreTools
/// <param name="logger">Logger object for file or console output</param>
/// <param name="norename">True if files should not be renamed with system and/or source in merged mode (default false)</param>
/// <param name="old">True if the output file should be in ClrMamePro format (default false)</param>
public Generate(string systemid, string sourceid, string datroot, string outroot, string connectionString, Logger logger, bool norename = false, bool old = false)
public GenerateTwo(string systemid, string sourceid, string datroot, string outroot, string connectionString, Logger logger, bool norename = false, bool old = false)
{
_systemid = systemid;
_sourceid = sourceid;

View File

@@ -9,7 +9,7 @@ using SabreTools.Helper;
namespace SabreTools
{
public class Import
public class ImportTwo : IImport
{
// Private instance variables
private string _datroot;
@@ -24,7 +24,7 @@ namespace SabreTools
/// <param name="connectionString">Connection string for SQLite</param>
/// <param name="logger">Logger object for file or console output</param>
/// <param name="ignore">False if each DAT that has no defined source asks for user input (default), true otherwise</param>
public Import(string datroot, string connectionString, Logger logger, bool ignore = false)
public ImportTwo(string datroot, string connectionString, Logger logger, bool ignore = false)
{
_datroot = datroot;
_connectionString = connectionString;

View File

@@ -0,0 +1,7 @@
namespace SabreTools.Helper
{
public interface IGenerate
{
bool Export();
}
}

View File

@@ -0,0 +1,7 @@
namespace SabreTools.Helper
{
public interface IImport
{
bool ImportData();
}
}

View File

@@ -94,6 +94,8 @@
<Compile Include="CRC32.cs" />
<Compile Include="DBTools.cs" />
<Compile Include="Data\Enums.cs" />
<Compile Include="Interfaces\IGenerate.cs" />
<Compile Include="Interfaces\IImport.cs" />
<Compile Include="Logger.cs" />
<Compile Include="Output.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />