Franz.Common.DependencyInjection 1.2.62

dotnet add package Franz.Common.DependencyInjection --version 1.2.62                
NuGet\Install-Package Franz.Common.DependencyInjection -Version 1.2.62                
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="Franz.Common.DependencyInjection" Version="1.2.62" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Franz.Common.DependencyInjection --version 1.2.62                
#r "nuget: Franz.Common.DependencyInjection, 1.2.62"                
#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 Franz.Common.DependencyInjection as a Cake Addin
#addin nuget:?package=Franz.Common.DependencyInjection&version=1.2.62

// Install Franz.Common.DependencyInjection as a Cake Tool
#tool nuget:?package=Franz.Common.DependencyInjection&version=1.2.62                

Franz.Common.DependencyInjection

A core library within the Franz Framework designed to simplify and enhance the usage of dependency injection in .NET applications. This package provides utilities and extensions for efficient registration of services, resolving dependencies, and managing lifetimes.


Features

  • Service Registration:
    • ServiceCollectionExtensions simplifies the registration of common service patterns.
  • Custom Strategies:
    • RegistrationStrategySkipExistingPair prevents duplicate service registrations, ensuring efficient dependency resolution.
  • Reflection Utilities:
    • ITypeSourceSelectorExtensions integrates with reflection-based service registration.
  • Modular Integration:
    • Works seamlessly with other Franz Framework libraries, including Franz.Common and Franz.Common.Reflection.

Version Information

  • Current Version: 1.2.62
  • Part of the private Franz Framework ecosystem.

Dependencies

This package relies on:

  • Microsoft.Extensions.DependencyInjection.Abstractions: Provides the core interfaces for dependency injection.
  • Scrutor (4.2.2): Enables advanced scanning and automatic service registration.
  • Franz.Common: Core utilities for the framework.
  • Franz.Common.Reflection: Reflection utilities for enhanced DI support.

Installation

From Private Azure Feed

Since this package is hosted privately, configure your NuGet client:

dotnet nuget add source "https://your-private-feed-url" \
  --name "AzurePrivateFeed" \
  --username "YourAzureUsername" \
  --password "YourAzurePassword" \
  --store-password-in-clear-text

Install the package:

dotnet add package Franz.Common.DependencyInjection --version 1.2.62

Usage

1. Service Registration

Use the ServiceCollectionExtensions to streamline the registration of services:

using Franz.Common.DependencyInjection.Extensions;

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddScoped<IOrderService, OrderService>(); // Example: Scoped registration
        services.AddSingleton<ILogger, Logger>(); // Example: Singleton registration
    }
}

2. Prevent Duplicate Registrations

Use RegistrationStrategySkipExistingPair to avoid redundant service registrations:

using Franz.Common.DependencyInjection.Extensions;

services.AddWithStrategy<ILogger, Logger>(new RegistrationStrategySkipExistingPair());

This ensures the service is only registered if it hasn’t been registered already.

3. Reflection-Based Registration

Automatically register services using reflection with ITypeSourceSelectorExtensions:

using Franz.Common.DependencyInjection.Extensions;

services.Scan(scan => scan
    .FromAssemblies(AppDomain.CurrentDomain.GetAssemblies())
    .AddClasses(classes => classes.AssignableTo<IService>())
    .AsImplementedInterfaces()
    .WithScopedLifetime());

Integration with Franz Framework

The Franz.Common.DependencyInjection package integrates seamlessly with:

  • Franz.Common: Provides foundational utilities.
  • Franz.Common.Reflection: Adds advanced reflection capabilities for dependency injection.

Ensure these dependencies are installed to leverage full functionality.


Contributing

This package is part of a private framework. Contributions are limited to the internal development team. If you have access, follow these steps:

  1. Clone the repository.
  2. Create a feature branch.
  3. Submit a pull request for review.

License

This library is licensed under the MIT License. See the LICENSE file for more details.


Changelog

Version 1.2.62

  • Introduced ServiceCollectionExtensions for streamlined service registration.
  • Added RegistrationStrategySkipExistingPair for efficient DI strategies.
  • Integrated ITypeSourceSelectorExtensions for reflection-based DI.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.

NuGet packages (13)

Showing the top 5 NuGet packages that depend on Franz.Common.DependencyInjection:

Package Downloads
Franz.Common.Business

Shared utility library for the Franz Framework.

Franz.Common.Messaging

Shared utility library for the Franz Framework.

Franz.Common.Headers

Shared utility library for the Franz Framework.

Franz.Common.EntityFramework

Shared utility library for the Franz Framework.

Franz.Common.Hosting

Shared utility library for the Franz Framework.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.62 125 1/8/2025