mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Create and implement IGenerate, IImport
This commit is contained in:
@@ -11,7 +11,7 @@ namespace SabreTools
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Entry class for the DATabase application
|
/// Entry class for the DATabase application
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class DATabase
|
public class DATabase
|
||||||
{
|
{
|
||||||
private static Logger logger;
|
private static Logger logger;
|
||||||
private static string _dbName = "DATabase.sqlite";
|
private static string _dbName = "DATabase.sqlite";
|
||||||
@@ -1298,7 +1298,7 @@ Make a selection:
|
|||||||
if (filename != "" && File.Exists(filename))
|
if (filename != "" && File.Exists(filename))
|
||||||
{
|
{
|
||||||
logger.User("Beginning import of " + 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();
|
bool success = imp.ImportData();
|
||||||
logger.User(filename + (success ? "" : " not") + " imported!");
|
logger.User(filename + (success ? "" : " not") + " imported!");
|
||||||
}
|
}
|
||||||
@@ -1308,7 +1308,7 @@ Make a selection:
|
|||||||
foreach (string file in Directory.GetFiles(filename, "*", SearchOption.AllDirectories))
|
foreach (string file in Directory.GetFiles(filename, "*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
logger.User("Beginning import of " + file);
|
logger.User("Beginning import of " + file);
|
||||||
Import imp = new Import(file, _connectionString, logger);
|
IImport imp = new Import(file, _connectionString, logger);
|
||||||
bool success = imp.ImportData();
|
bool success = imp.ImportData();
|
||||||
logger.User(file + (success ? "" : " not") + " imported!");
|
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>
|
/// <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)
|
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();
|
gen.Export();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace SabreTools
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a DAT from the data in the database
|
/// Generate a DAT from the data in the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class Generate
|
class Generate : IGenerate
|
||||||
{
|
{
|
||||||
// Private instance variables
|
// Private instance variables
|
||||||
private string _systems;
|
private string _systems;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.Sqlite;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml;
|
|
||||||
|
|
||||||
using SabreTools.Helper;
|
using SabreTools.Helper;
|
||||||
|
|
||||||
@@ -12,7 +10,7 @@ namespace SabreTools
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Import data into the database from existing DATs
|
/// Import data into the database from existing DATs
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Import
|
public class Import : IImport
|
||||||
{
|
{
|
||||||
// Private instance variables
|
// Private instance variables
|
||||||
private string _filepath;
|
private string _filepath;
|
||||||
|
|||||||
@@ -77,8 +77,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="DATabaseTwo.cs" />
|
<Compile Include="DATabaseTwo.cs" />
|
||||||
<Compile Include="Generate.cs" />
|
<Compile Include="GenerateTwo.cs" />
|
||||||
<Compile Include="Import.cs" />
|
<Compile Include="ImportTwo.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using SabreTools.Helper;
|
|||||||
|
|
||||||
namespace SabreTools
|
namespace SabreTools
|
||||||
{
|
{
|
||||||
public class Generate
|
public class GenerateTwo : IGenerate
|
||||||
{
|
{
|
||||||
// Private instance variables
|
// Private instance variables
|
||||||
private string _systemid;
|
private string _systemid;
|
||||||
@@ -35,7 +35,7 @@ namespace SabreTools
|
|||||||
/// <param name="logger">Logger object for file or console output</param>
|
/// <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="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>
|
/// <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;
|
_systemid = systemid;
|
||||||
_sourceid = sourceid;
|
_sourceid = sourceid;
|
||||||
@@ -9,7 +9,7 @@ using SabreTools.Helper;
|
|||||||
|
|
||||||
namespace SabreTools
|
namespace SabreTools
|
||||||
{
|
{
|
||||||
public class Import
|
public class ImportTwo : IImport
|
||||||
{
|
{
|
||||||
// Private instance variables
|
// Private instance variables
|
||||||
private string _datroot;
|
private string _datroot;
|
||||||
@@ -24,7 +24,7 @@ namespace SabreTools
|
|||||||
/// <param name="connectionString">Connection string for SQLite</param>
|
/// <param name="connectionString">Connection string for SQLite</param>
|
||||||
/// <param name="logger">Logger object for file or console output</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>
|
/// <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;
|
_datroot = datroot;
|
||||||
_connectionString = connectionString;
|
_connectionString = connectionString;
|
||||||
7
SabreHelper/Interfaces/IGenerate.cs
Normal file
7
SabreHelper/Interfaces/IGenerate.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace SabreTools.Helper
|
||||||
|
{
|
||||||
|
public interface IGenerate
|
||||||
|
{
|
||||||
|
bool Export();
|
||||||
|
}
|
||||||
|
}
|
||||||
7
SabreHelper/Interfaces/IImport.cs
Normal file
7
SabreHelper/Interfaces/IImport.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace SabreTools.Helper
|
||||||
|
{
|
||||||
|
public interface IImport
|
||||||
|
{
|
||||||
|
bool ImportData();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -94,6 +94,8 @@
|
|||||||
<Compile Include="CRC32.cs" />
|
<Compile Include="CRC32.cs" />
|
||||||
<Compile Include="DBTools.cs" />
|
<Compile Include="DBTools.cs" />
|
||||||
<Compile Include="Data\Enums.cs" />
|
<Compile Include="Data\Enums.cs" />
|
||||||
|
<Compile Include="Interfaces\IGenerate.cs" />
|
||||||
|
<Compile Include="Interfaces\IImport.cs" />
|
||||||
<Compile Include="Logger.cs" />
|
<Compile Include="Logger.cs" />
|
||||||
<Compile Include="Output.cs" />
|
<Compile Include="Output.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user