Add common project and move some classes out of code into it
This commit is contained in:
parent
11ad866348
commit
554c86d7db
14
Bots.sln
14
Bots.sln
@ -3,7 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.31424.327
|
VisualStudioVersion = 16.0.31424.327
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generator", "Generator\Generator.csproj", "{79CD3722-D6A7-4BA1-8CDF-533A77566D93}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Generator", "Generator\Generator.csproj", "{79CD3722-D6A7-4BA1-8CDF-533A77566D93}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PMCGenerator", "PMCGenerator\PMCGenerator.csproj", "{AA738C3F-2BA0-4754-A7A7-82E290BF51CA}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{DE50047B-01AB-4B99-A270-95C8F6101D0D}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -15,6 +19,14 @@ Global
|
|||||||
{79CD3722-D6A7-4BA1-8CDF-533A77566D93}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{79CD3722-D6A7-4BA1-8CDF-533A77566D93}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{79CD3722-D6A7-4BA1-8CDF-533A77566D93}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{79CD3722-D6A7-4BA1-8CDF-533A77566D93}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{79CD3722-D6A7-4BA1-8CDF-533A77566D93}.Release|Any CPU.Build.0 = Release|Any CPU
|
{79CD3722-D6A7-4BA1-8CDF-533A77566D93}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{AA738C3F-2BA0-4754-A7A7-82E290BF51CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AA738C3F-2BA0-4754-A7A7-82E290BF51CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{AA738C3F-2BA0-4754-A7A7-82E290BF51CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{AA738C3F-2BA0-4754-A7A7-82E290BF51CA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{DE50047B-01AB-4B99-A270-95C8F6101D0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{DE50047B-01AB-4B99-A270-95C8F6101D0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{DE50047B-01AB-4B99-A270-95C8F6101D0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{DE50047B-01AB-4B99-A270-95C8F6101D0D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
7
Common/Common.csproj
Normal file
7
Common/Common.csproj
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
16
Common/DiskHelpers.cs
Normal file
16
Common/DiskHelpers.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Common
|
||||||
|
{
|
||||||
|
public static class DiskHelpers
|
||||||
|
{
|
||||||
|
public static void CreateDirIfDoesntExist(string path)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists($"{path}"))
|
||||||
|
{
|
||||||
|
//create dump dir
|
||||||
|
Directory.CreateDirectory($"{path}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
Common/Extensions/StringToolsExtensions.cs
Normal file
16
Common/Extensions/StringToolsExtensions.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Common.Extensions
|
||||||
|
{
|
||||||
|
public static class StringToolsExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Add a string to a list only if it doesnt already exist
|
||||||
|
/// </summary>
|
||||||
|
public static void AddUnique(this IList<string> self, string item)
|
||||||
|
{
|
||||||
|
if (!self.Contains(item))
|
||||||
|
self.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
Common/LoggingHelpers.cs
Normal file
28
Common/LoggingHelpers.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Common
|
||||||
|
{
|
||||||
|
public static class LoggingHelpers
|
||||||
|
{
|
||||||
|
public static string LogTimeTaken(double totalSeconds)
|
||||||
|
{
|
||||||
|
return Math.Round(totalSeconds, 2, MidpointRounding.ToEven).ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogToConsole(string message, ConsoleColor backgroundColour = ConsoleColor.Green)
|
||||||
|
{
|
||||||
|
Console.BackgroundColor = backgroundColour;
|
||||||
|
Console.ForegroundColor = ConsoleColor.Black;
|
||||||
|
|
||||||
|
Console.WriteLine(message);
|
||||||
|
|
||||||
|
ResetConsoleColours();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ResetConsoleColours()
|
||||||
|
{
|
||||||
|
Console.BackgroundColor = ConsoleColor.Black;
|
||||||
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user