From 80b293eec1d000c927ca105c1758e0ab4badb577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=A4felfinger?= Date: Tue, 11 Jul 2023 18:37:36 +0200 Subject: [PATCH] adds first version of microsoft di support for piwigodotnet --- .../Piwigo.Client.Autofac.csproj | 2 +- .../Piwigo.Client.DependencyInjection.csproj | 17 +++++++++++++++ .../ServiceCollectionExtension.cs | 21 +++++++++++++++++++ .../Piwigo.Client.Tests.csproj | 6 +++--- src/PiwigoDotnet.sln | 6 ++++++ 5 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 src/Piwigo.Client.DependencyInjection/Piwigo.Client.DependencyInjection.csproj create mode 100644 src/Piwigo.Client.DependencyInjection/ServiceCollectionExtension.cs diff --git a/src/Piwigo.Client.Autofac/Piwigo.Client.Autofac.csproj b/src/Piwigo.Client.Autofac/Piwigo.Client.Autofac.csproj index 32036dc..5fd2899 100644 --- a/src/Piwigo.Client.Autofac/Piwigo.Client.Autofac.csproj +++ b/src/Piwigo.Client.Autofac/Piwigo.Client.Autofac.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/Piwigo.Client.DependencyInjection/Piwigo.Client.DependencyInjection.csproj b/src/Piwigo.Client.DependencyInjection/Piwigo.Client.DependencyInjection.csproj new file mode 100644 index 0000000..1082cc2 --- /dev/null +++ b/src/Piwigo.Client.DependencyInjection/Piwigo.Client.DependencyInjection.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/src/Piwigo.Client.DependencyInjection/ServiceCollectionExtension.cs b/src/Piwigo.Client.DependencyInjection/ServiceCollectionExtension.cs new file mode 100644 index 0000000..b401cdd --- /dev/null +++ b/src/Piwigo.Client.DependencyInjection/ServiceCollectionExtension.cs @@ -0,0 +1,21 @@ +using Microsoft.Extensions.DependencyInjection; +using Piwigo.Client.Albums; +using Piwigo.Client.Images; +using Piwigo.Client.Session; +using Piwigo.Client.Tags; + +namespace Piwigo.Client.DependencyInjection; + +public static class ServiceCollectionExtension +{ + public static void AddPiwigoClient(this ServiceCollection services, IPiwigoConfiguration configuration) + { + services.AddSingleton(configuration); + services.AddScoped(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + } +} \ No newline at end of file diff --git a/src/Piwigo.Client.Tests/Piwigo.Client.Tests.csproj b/src/Piwigo.Client.Tests/Piwigo.Client.Tests.csproj index 984d55e..84bef21 100644 --- a/src/Piwigo.Client.Tests/Piwigo.Client.Tests.csproj +++ b/src/Piwigo.Client.Tests/Piwigo.Client.Tests.csproj @@ -9,15 +9,15 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/PiwigoDotnet.sln b/src/PiwigoDotnet.sln index ad41f94..467c01e 100644 --- a/src/PiwigoDotnet.sln +++ b/src/PiwigoDotnet.sln @@ -8,6 +8,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Piwigo.Client.Cli", "Piwigo EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Piwigo.Client.Autofac", "Piwigo.Client.Autofac\Piwigo.Client.Autofac.csproj", "{C8247110-D9BB-4658-B36B-7AEB7A42C8EC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Piwigo.Client.DependencyInjection", "Piwigo.Client.DependencyInjection\Piwigo.Client.DependencyInjection.csproj", "{76166A7A-92DD-4A7F-B3BA-C5176213EC84}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -30,5 +32,9 @@ Global {C8247110-D9BB-4658-B36B-7AEB7A42C8EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {C8247110-D9BB-4658-B36B-7AEB7A42C8EC}.Release|Any CPU.ActiveCfg = Release|Any CPU {C8247110-D9BB-4658-B36B-7AEB7A42C8EC}.Release|Any CPU.Build.0 = Release|Any CPU + {76166A7A-92DD-4A7F-B3BA-C5176213EC84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {76166A7A-92DD-4A7F-B3BA-C5176213EC84}.Debug|Any CPU.Build.0 = Debug|Any CPU + {76166A7A-92DD-4A7F-B3BA-C5176213EC84}.Release|Any CPU.ActiveCfg = Release|Any CPU + {76166A7A-92DD-4A7F-B3BA-C5176213EC84}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal