Mgft.Core.Common.DI.Services 1.0.1

dotnet add package Mgft.Core.Common.DI.Services --version 1.0.1
NuGet\Install-Package Mgft.Core.Common.DI.Services -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mgft.Core.Common.DI.Services" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mgft.Core.Common.DI.Services --version 1.0.1
#r "nuget: Mgft.Core.Common.DI.Services, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Mgft.Core.Common.DI.Services as a Cake Addin
#addin nuget:?package=Mgft.Core.Common.DI.Services&version=1.0.1

// Install Mgft.Core.Common.DI.Services as a Cake Tool
#tool nuget:?package=Mgft.Core.Common.DI.Services&version=1.0.1

Exmaple:

  1. Implement ICustomServiceWrapper<> for the multi-instance service
    public class CustomTopicClient : ICustomServiceWrapper<ITopicClient>
    {
        public string Name { get; }
        public ITopicClient CustomService { get; }

        public CustomTopicClient(string name, ITopicClient customService)
        {
            Name = name;
            CustomService = customService;
        }
    }
  1. Register multiple instance in the Container
    services.AddSingleton<ICustomServiceWrapper<ITopicClient>>(opt => {
        var client = new TopicClient("Some ConnStr", "Topic-1");
        var customService = new CustomTopicClient("Instance-1", client);
        return customService;
    });

    services.AddSingleton<ICustomServiceWrapper<ITopicClient>>(opt => {
        var client = new TopicClient("Some ConnStr", "Topic-2");
        var customService = new CustomTopicClient("Instance-2", client);
        return customService;
    });
  1. Resolve the Instance in your class
    public class QueueReport
        {
            private readonly CustomServiceResolver<ITopicClient, ICustomServiceWrapper<ITopicClient>> _serviceResolver;
            private readonly ITopicClient _client
        
            public QueueReport(CustomServiceResolver<ITopicClient, ICustomServiceWrapper<ITopicClient>> serviceResolver)
            {
                _serviceResolver = serviceResolver;
                _client = _serviceResolver.GetServiceByName("Instance-1");
            }

            public async Task Handle(AccessVerifiedEvent notification, CancellationToken cancellationToken)
            {
                await _client.SendAsync(Message);
           
            }
        }
    }
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 172 11/27/2022

Add AddAppSettings