Skip to content

Stashbox v5.8.0

Compare
Choose a tag to compare
@z4kn4fein z4kn4fein released this 28 Feb 11:14

Fixed

  • Batch registration (like .RegisterAssembly() and .RegisterTypes()) produced individual registrations for each interface/base type and implementation type pairs.

    For an example class like class Sample : ISample1, ISample2 { } the registration mapping looked like this:

    ISample1 => NewRegistrationOf(Sample)
    ISample2 => NewRegistrationOf(Sample)
    

    Now each interface/base type is mapped to the same registration:

     registration = NewRegistrationOf(Sample)
     ISample1 => registration
     ISample2 => registration
    

Changed

  • There are cases where the above fix for batch registration indirectly breaks the following service type filter format:

    container.RegisterAssemblyContaining<ISample>(configurator: options =>
        {
            if (options.ServiceType == typeof(IService))
                context.WithScopedLifetime();
        });

    This worked before (and still works if the related service implements only a single type) because for each implemented type there was an individual registration configuration object passed to the configurator delegate.

    Now it will not work properly if the bound type implements more than one type, as only one object containing each implemented type is passed to the delegate.

    Therefore, to still support this case, a new service type checker method was introduced:

    container.RegisterAssemblyContaining<ISample>(configurator: options =>
        {
            if (options.HasServiceType<IService>()) // or .HasServiceType(typeof(IService))
                context.WithScopedLifetime();
        });