Tx.Core.DI.Multiple.Intances 1.0.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Tx.Core.DI.Multiple.Intances --version 1.0.1.1                
NuGet\Install-Package Tx.Core.DI.Multiple.Intances -Version 1.0.1.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="Tx.Core.DI.Multiple.Intances" Version="1.0.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tx.Core.DI.Multiple.Intances --version 1.0.1.1                
#r "nuget: Tx.Core.DI.Multiple.Intances, 1.0.1.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 Tx.Core.DI.Multiple.Intances as a Cake Addin
#addin nuget:?package=Tx.Core.DI.Multiple.Intances&version=1.0.1.1

// Install Tx.Core.DI.Multiple.Intances as a Cake Tool
#tool nuget:?package=Tx.Core.DI.Multiple.Intances&version=1.0.1.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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.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.1.2025.10 70 13 days ago
1.0.2 331 11/28/2022
1.0.1.1 300 11/27/2022

Upgrate to net6.0