Loose coupling of data models using interfaces
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using FireLance.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DevConsole
|
||||
@@ -101,7 +102,7 @@ namespace DevConsole
|
||||
}
|
||||
#endregion
|
||||
|
||||
private static void PrintGameEntries(List<GameEntryModal> gameEntries)
|
||||
private static void PrintGameEntries(IEnumerable<IGameEntry> gameEntries)
|
||||
{
|
||||
foreach (var game in gameEntries)
|
||||
{
|
||||
@@ -113,7 +114,7 @@ namespace DevConsole
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintDirectories(List<DirectoriesModel> directoryEntries)
|
||||
private static void PrintDirectories(IEnumerable<IDirectories> directoryEntries)
|
||||
{
|
||||
foreach (var directory in directoryEntries)
|
||||
{
|
||||
|
||||
+8
-2
@@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30204.135
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GSMParser", "GSMParser\GSMParser.csproj", "{7344FC11-3894-4393-A558-82E7D671372D}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GSMParser", "GSMParser\GSMParser.csproj", "{7344FC11-3894-4393-A558-82E7D671372D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DevConsole", "DevConsole\DevConsole.csproj", "{6B7A9B29-420B-4F58-975E-3D72A3D95314}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevConsole", "DevConsole\DevConsole.csproj", "{6B7A9B29-420B-4F58-975E-3D72A3D95314}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FireLance", "FireLance\FireLance.csproj", "{6ACF5E6F-42EE-4FD6-8657-51E6380D422C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -21,6 +23,10 @@ Global
|
||||
{6B7A9B29-420B-4F58-975E-3D72A3D95314}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6B7A9B29-420B-4F58-975E-3D72A3D95314}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6B7A9B29-420B-4F58-975E-3D72A3D95314}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6ACF5E6F-42EE-4FD6-8657-51E6380D422C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6ACF5E6F-42EE-4FD6-8657-51E6380D422C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6ACF5E6F-42EE-4FD6-8657-51E6380D422C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6ACF5E6F-42EE-4FD6-8657-51E6380D422C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace FireLance
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace FireLance.Interfaces
|
||||
{
|
||||
public interface IDirectories
|
||||
{
|
||||
int id { get; set; }
|
||||
int GameID { get; set; }
|
||||
string SpecialPath { get; set; }
|
||||
string Path { get; set; }
|
||||
string RegHive { get; set; }
|
||||
string RegPath { get; set; }
|
||||
string RegValue { get; set; }
|
||||
string DefinedFiles { get; set; }
|
||||
string ExcludedFiles { get; set; }
|
||||
bool Recurse { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace FireLance.Interfaces
|
||||
{
|
||||
public interface IGameEntry
|
||||
{
|
||||
int id { get; set; }
|
||||
string GameName { get; set; }
|
||||
string BackupWarning { get; set; }
|
||||
string RestoreWarning { get; set; }
|
||||
string LastModified { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
public class DirectoriesModel
|
||||
public class DirectoriesModel : FireLance.Interfaces.IDirectories
|
||||
{
|
||||
public int id { get; set; }
|
||||
public int GameID { get; set; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Data.Common;
|
||||
|
||||
public class GameEntryModal
|
||||
public class GameEntryModal : FireLance.Interfaces.IGameEntry
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string GameName { get; set; }
|
||||
@@ -10,6 +10,10 @@
|
||||
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="3.1.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FireLance\FireLance.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="games.db">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
|
||||
+7
-6
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Dapper;
|
||||
using FireLance.Interfaces;
|
||||
|
||||
public class GSMParser
|
||||
{
|
||||
@@ -29,18 +30,18 @@ public class GSMParser
|
||||
return Convert.ToString(DBConnection.State);
|
||||
}
|
||||
|
||||
public List<GameEntryModal> QueryGameById(string id)
|
||||
public IEnumerable<IGameEntry> QueryGameById(string id)
|
||||
{
|
||||
return (List<GameEntryModal>)DBConnection.Query<GameEntryModal>(QueryBuilder.GameEntryByGameId(id), new DynamicParameters());
|
||||
return (IEnumerable<IGameEntry>)DBConnection.Query<GameEntryModal>(QueryBuilder.GameEntryByGameId(id), new DynamicParameters());
|
||||
}
|
||||
|
||||
public List<DirectoriesModel> QueryDirectoryById(string id)
|
||||
public IEnumerable<IDirectories> QueryDirectoryById(string id)
|
||||
{
|
||||
return (List<DirectoriesModel>)DBConnection.Query<DirectoriesModel>(QueryBuilder.DirectoryByGameId(id), new DynamicParameters());
|
||||
return (IEnumerable<IDirectories>)DBConnection.Query<DirectoriesModel>(QueryBuilder.DirectoryByGameId(id), new DynamicParameters());
|
||||
}
|
||||
|
||||
public List<GameEntryModal> QueryGameByName(string name)
|
||||
public IEnumerable<IGameEntry> QueryGameByName(string name)
|
||||
{
|
||||
return (List<GameEntryModal>) DBConnection.Query<GameEntryModal>(QueryBuilder.GameEntryByName(name), new DynamicParameters());
|
||||
return (IEnumerable<IGameEntry>) DBConnection.Query<GameEntryModal>(QueryBuilder.GameEntryByName(name), new DynamicParameters());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user