From 73d17fdb12f3216b1d407f40e422da59da513944 Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Sun, 26 Oct 2025 17:57:52 +0100 Subject: [PATCH] Add MediaOrganizer project --- Directory.Build.props | 2 + Directory.Build.targets | 2 + global.json | 2 + media-organizer.sln | 27 ++++++++++ src/Program.cs | 93 +++++++++++++++++++++++++++++++++ src/Properties/appsettings.json | 2 + src/appsettings.json | 0 src/media-organizer.csproj | 42 +++++++++++++++ 8 files changed, 170 insertions(+) create mode 100755 Directory.Build.props create mode 100755 Directory.Build.targets create mode 100755 global.json create mode 100755 media-organizer.sln create mode 100755 src/Program.cs create mode 100755 src/Properties/appsettings.json create mode 100755 src/appsettings.json create mode 100755 src/media-organizer.csproj diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100755 index 0000000..8c119d5 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,2 @@ + + diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100755 index 0000000..8c119d5 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,2 @@ + + diff --git a/global.json b/global.json new file mode 100755 index 0000000..7a73a41 --- /dev/null +++ b/global.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/media-organizer.sln b/media-organizer.sln new file mode 100755 index 0000000..c375169 --- /dev/null +++ b/media-organizer.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "media-organizer", "src\media-organizer.csproj", "{E34F9D32-207E-4897-9CEC-26156FBD1B4D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E34F9D32-207E-4897-9CEC-26156FBD1B4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E34F9D32-207E-4897-9CEC-26156FBD1B4D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E34F9D32-207E-4897-9CEC-26156FBD1B4D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E34F9D32-207E-4897-9CEC-26156FBD1B4D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {E34F9D32-207E-4897-9CEC-26156FBD1B4D} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B} + EndGlobalSection +EndGlobal diff --git a/src/Program.cs b/src/Program.cs new file mode 100755 index 0000000..c93d2ea --- /dev/null +++ b/src/Program.cs @@ -0,0 +1,93 @@ +#pragma warning disable IDE0079 +#pragma warning disable IDE0005 +global using static Program; +#pragma warning restore + +// Media Organizer + +using System.Text.RegularExpressions; + +using ConsoleAppFramework; + +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration.Json; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.FileProviders; + +ConfigurationManager configuration = new(); +ManifestEmbeddedFileProvider embeddedFileProvider = new(typeof(Program).Assembly, "Properties"); +configuration.Sources.Insert(0, new JsonConfigurationSource() +{ + FileProvider = embeddedFileProvider, + Path = "appsettings.json", + Optional = true, + ReloadOnChange = true +}); + +configuration.AddEnvironmentVariables("DOTNET_"); + +const string environment = +#if DEBUG + "Development" +#else + "Production" +#endif +; +var environmentAppSettingsName = $"appsettings.{configuration.GetValue("Environment", environment)}.json"; + +configuration.Sources.Insert(2, new JsonConfigurationSource() +{ + FileProvider = embeddedFileProvider, + Path = environmentAppSettingsName, + Optional = true, + ReloadOnChange = true +}); +PhysicalFileProvider baseDirectoryFileProvider = new(AppContext.BaseDirectory); +configuration.Sources.Insert(3, new JsonConfigurationSource() +{ + FileProvider = baseDirectoryFileProvider, + Path = "appsettings.json", + Optional = true, + ReloadOnChange = true +}); +configuration.Sources.Insert(4, new JsonConfigurationSource() +{ + FileProvider = baseDirectoryFileProvider, + Path = environmentAppSettingsName, + Optional = true, + ReloadOnChange = true +}); +PhysicalFileProvider currentDirectoryFileProvider = new(Environment.CurrentDirectory); +configuration.Sources.Insert(5, new JsonConfigurationSource() +{ + FileProvider = currentDirectoryFileProvider, + Path = "appsettings.json", + Optional = true, + ReloadOnChange = true +}); +configuration.Sources.Insert(6, new JsonConfigurationSource() +{ + FileProvider = currentDirectoryFileProvider, + Path = environmentAppSettingsName, + Optional = true, + ReloadOnChange = true +}); + +// Configuration Sources: +// - Embedded: Properties\appsettings.json +// - InMemory +// - Embedded: Properties\appsettings.${Environment}.json +// - Physical: BaseDirectory\appsettings.json +// - Physical: BaseDirectory\appsettings${Environment}.json +// - Physical: CurrentDirectory\appsettings.json +// - Physical: CurrentDirectory\appsettings${Environment}.json + +ServiceCollection services = new(); +services.AddSingleton(configuration); +services.AddOptions(); +ConsoleApp.ServiceProvider = services.BuildServiceProvider(); +ConsoleApp.Create().Run(args); + +internal static partial class Program +{ +} diff --git a/src/Properties/appsettings.json b/src/Properties/appsettings.json new file mode 100755 index 0000000..7a73a41 --- /dev/null +++ b/src/Properties/appsettings.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/src/appsettings.json b/src/appsettings.json new file mode 100755 index 0000000..e69de29 diff --git a/src/media-organizer.csproj b/src/media-organizer.csproj new file mode 100755 index 0000000..88e77ec --- /dev/null +++ b/src/media-organizer.csproj @@ -0,0 +1,42 @@ + + + + Exe + net8.0 + MediaOrganizer + enable + enable + false + + + + true + true + true + true + preview + false + partial + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + + + \ No newline at end of file