From 2d6f6ba97ccfb670a21742406644338252fc31f3 Mon Sep 17 00:00:00 2001 From: Alex Loren Date: Wed, 12 Jul 2023 11:08:53 -0700 Subject: [PATCH] Added service injection extension, bumped version --- .../Extensions/ServiceCollectionExtension.cs | 20 +++++++++++++++++++ StrapiSharp/StrapiSharp.csproj | 7 ++++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 StrapiSharp/Extensions/ServiceCollectionExtension.cs diff --git a/StrapiSharp/Extensions/ServiceCollectionExtension.cs b/StrapiSharp/Extensions/ServiceCollectionExtension.cs new file mode 100644 index 0000000..b9574d5 --- /dev/null +++ b/StrapiSharp/Extensions/ServiceCollectionExtension.cs @@ -0,0 +1,20 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace StrapiSharp.Extensions +{ + public static class ServiceCollectionExtension + { + /// + /// Adds a object as a singleton instance. + /// + /// . + /// The Strapi host to make requests against. + /// Continues the chain. + public static IServiceCollection AddStrapiSharp(this IServiceCollection services, string host) + { + services.AddSingleton(new Strapi(host)); + return services; + } + } +} + diff --git a/StrapiSharp/StrapiSharp.csproj b/StrapiSharp/StrapiSharp.csproj index df5328c..a1d7c4b 100644 --- a/StrapiSharp/StrapiSharp.csproj +++ b/StrapiSharp/StrapiSharp.csproj @@ -5,7 +5,7 @@ enable enable StrapiSharp - 0.1.3 + 0.1.4 Alex Loren Strapi;REST;API StrapiSharp is a lightweight C# library for easy integration with Strapi CMS, allowing seamless communication with Strapi's RESTful API. @@ -21,11 +21,16 @@ + + + + +