Firelance 0.1.0.0

- Corrected instancing error by including FQ class name from previous commit
- Implemented helper class:
  - SpecialPath directory converter
  - Registry value parser
This commit is contained in:
2020-07-07 20:07:33 +01:00
parent 02e7b8db4c
commit 06e4c505db
3 changed files with 98 additions and 25 deletions
+46 -25
View File
@@ -1,6 +1,5 @@
using Firelance;
using Firelance.Models;
using Gsm;
using Firelance.Models;
using FirelanceMgr;
using MongoDB.Bson;
using System;
using System.Collections.Generic;
@@ -11,8 +10,8 @@ namespace DevConsole
{
class Program
{
public static GsmMgr gsmMgr = new GsmMgr();
public static FirelanceMgr flcMgr = new FirelanceMgr();
public static Gsm.GsmMgr gsmMgr = new Gsm.GsmMgr();
public static Firelance.FirelanceMgr flcMgr = new Firelance.FirelanceMgr();
static void Main(string[] args)
{
@@ -28,6 +27,7 @@ namespace DevConsole
Console.WriteLine("A. Manage DB Connections --->");
Console.WriteLine("B. GSM Actions --->");
Console.WriteLine("C. FLC Actions --->");
Console.WriteLine("D. Helper Actions --->");
Console.WriteLine("X. Exit application\n");
Console.Write(":");
@@ -45,6 +45,9 @@ namespace DevConsole
case "C":
CmdFlcActions();
break;
case "D":
CmdHelperActions();
break;
case "X":
Environment.Exit(0);
break;
@@ -117,10 +120,10 @@ namespace DevConsole
Console.WriteLine("Enter a game ID:");
var queryId = gsmMgr.RO.LoadRecords<GameEntryModel>( Gsm.Collections.Columns.GameName,
Gsm.Collections.Tables.GameEntry,
Gsm.Collections.Columns.ID,
Console.ReadLine(),
true);
Gsm.Collections.Tables.GameEntry,
Gsm.Collections.Columns.ID,
Console.ReadLine(),
true);
foreach (var record in queryId) PrintAllValues(record);
break;
@@ -128,20 +131,20 @@ namespace DevConsole
Console.WriteLine("Enter a game ID:");
var queryDirectoryId = gsmMgr.RO.LoadRecords<DirectoriesModel>( Gsm.Collections.Options.All,
Gsm.Collections.Tables.Directories,
Gsm.Collections.Columns.GameID,
Console.ReadLine(),
true);
Gsm.Collections.Tables.Directories,
Gsm.Collections.Columns.GameID,
Console.ReadLine(),
true);
foreach (var record in queryDirectoryId) PrintAllValues(record);
break;
case "C":
Console.WriteLine("Enter game title to search:");
var queryGameByName = gsmMgr.RO.LoadRecords<GameEntryModel>( Gsm.Collections.Columns.GameName,
Gsm.Collections.Tables.GameEntry,
Gsm.Collections.Columns.GameName,
Console.ReadLine(),
false);
Gsm.Collections.Tables.GameEntry,
Gsm.Collections.Columns.GameName,
Console.ReadLine(),
false);
foreach (var record in queryGameByName) PrintAllValues(record);
break;
case "X":
@@ -188,22 +191,40 @@ namespace DevConsole
}
}
private static void CmdHelperActions()
{
Console.WriteLine("A. Convert SpecialPath to AbsolutePath");
Console.WriteLine("X. <--- Go back\n");
Console.Write(":");
var userInput = Console.ReadLine();
Console.Write("\n\n");
switch (userInput.ToUpper())
{
case "A":
Console.WriteLine(Helpers.Converters.GetSpecialToAbsolutePath(Console.ReadLine().ToUpper()));
break;
case "X":
break;
}
}
#endregion
#region FlcActions
private static void FlcWriteMasterGameRecordAction()
{
var masterGameRecord = new MasterGameRecordModel();
List<DirectoriesModel> directories = gsmMgr.RO.LoadRecords<DirectoriesModel>( Gsm.Collections.Options.All,
Gsm.Collections.Tables.Directories,
Gsm.Collections.Columns.GameID,
"600",
true);
Gsm.Collections.Tables.Directories,
Gsm.Collections.Columns.GameID,
"600",
true);
GameEntryModel gameEntry = gsmMgr.RO.LoadRecords<GameEntryModel>( Gsm.Collections.Columns.GameName,
Gsm.Collections.Tables.GameEntry,
Gsm.Collections.Columns.ID,
"600",
true).First();
Gsm.Collections.Tables.GameEntry,
Gsm.Collections.Columns.ID,
"600",
true).First();
List<SaveGameEntriesModel> saveGameEntries = new List<SaveGameEntriesModel>();
saveGameEntries.Add(new SaveGameEntriesModel());
+1
View File
@@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
<PackageReference Include="MongoDB.Driver" Version="2.10.4" />
<PackageReference Include="MongoDB.Driver.GridFS" Version="2.10.4" />
</ItemGroup>
+51
View File
@@ -0,0 +1,51 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
namespace FirelanceMgr
{
public static class Helpers
{
public static class Converters
{
public static string GetSpecialToAbsolutePath(string specialPath)
{
var d = new Dictionary<string, string>()
{
{ "%APPDATA%", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) },
{ "%APPDATA_LOCAL%", Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) },
{ "%APPDATA_LOCALLOW%", @$"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\AppData\LocalLow" },
{ "%APPDATA_COMMON%", Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) },
{ "%DOCUMENTS%", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) },
{ "%SAVED_GAMES%", @$"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\Saved Games" },
{ "%STEAM%", Parsers.GetValueFromRegistry(@"SOFTWARE\WOW6432Node\Valve\Steam", "InstallPath") },
{ "%STEAM_CLOUD%", $@"{Parsers.GetValueFromRegistry(@"SOFTWARE\WOW6432Node\Valve\Steam", "InstallPath")}\userdata" },
{ "%SHARED_DOCUMENTS%", Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments) },
{ "%USER_PROFILE%", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) },
{ "%UPLAY%", "NOT_YET_IMPLEMENTED" },
};
return d.Where(x => x.Key.Contains(specialPath)).Select(x => x.Value).Single();
}
}
public static class Parsers
{
public static string GetValueFromRegistry(string subKey, string value)
{
string result = string.Empty;
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(subKey))
{
if (key != null)
{
result = key.GetValue(value).ToString();
}
}
return result;
}
}
}
}