-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f62dda2
commit ad15795
Showing
8 changed files
with
120 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace SC_Interfaces; | ||
public interface IRunWatcherDetect | ||
{ | ||
public string Folder { get; set; } | ||
public IRunWatcher[] DetectVersions(); | ||
} | ||
|
||
public interface IRunWatcher | ||
{ | ||
public int Version { get; } | ||
public Task<int> Run(string[] args); | ||
|
||
} | ||
|
||
public interface IRunWatcherV1: IRunWatcher | ||
{ | ||
public int DelaySeconds { get; set; } | ||
|
||
} | ||
|
||
public interface IRunWatcherFile | ||
{ | ||
public Version DetectFile(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Microsoft.Extensions.Logging.Abstractions; | ||
|
||
public class Program | ||
{ | ||
public static async Task<int> Main(string[] args) | ||
{ | ||
var services = CreateServices(); | ||
var watcher = services.GetRequiredService<IRunWatcherDetect>(); | ||
ArgumentNullException.ThrowIfNull(watcher, nameof(watcher)); | ||
watcher.Folder = Environment.CurrentDirectory; | ||
var logger= services.GetRequiredService<ILogger<Program>>(); | ||
var versions = await watcher.DetectVersions(); | ||
if (versions.Length == 0) | ||
{ | ||
logger.LogError("No versions detected"); | ||
throw new InvalidOperationException("No versions detected"); | ||
} | ||
var lastVersion = versions.OrderByDescending(v => v.Version).First(); | ||
logger.LogInformation($"Running version {lastVersion.Version}"); | ||
return await lastVersion.Run(args); | ||
|
||
} | ||
private static ServiceProvider CreateServices() | ||
{ | ||
var serviceProvider = new ServiceCollection() | ||
//.AddSingleton<IRunWatcher>((IRunWatcher)null) | ||
//.AddSingleton<ILogger>(new NullLogger()) | ||
.BuildServiceProvider(); | ||
|
||
return serviceProvider; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PublishAot>true</PublishAot> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\SC_Interfaces\SC_Interfaces.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
global using SC_Interfaces; | ||
global using Microsoft.Extensions.DependencyInjection; | ||
global using System; | ||
global using Microsoft.Extensions.Logging; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters