Skip to content

RegisterTypes extension ignoring 'overwriteExistingMappings' flag #5

@BigPeeg

Description

@BigPeeg

If a type is registered in a Unity container where the interface and class follow the same pattern as used in 'registration by convention', when the RegisterTypes extension is used to register by convention, the original mapping is over-written despite the 'overwriteExistingMappings' flag of the extension method being set to 'false'.

`

        var container = new UnityContainer();
        container.RegisterType<IAppTester, AppTester>(new PerThreadLifetimeManager());

        container.RegisterTypes(
            AllClasses.FromLoadedAssemblies(),
            WithMappings.FromMatchingInterface,
            WithName.Default);

        container.Registrations.First(r => r.RegisteredType.Equals(typeof(IAppTester))).LifetimeManager.GetType().Should().Be<PerThreadLifetimeManager>("specifically registered type should remain");

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions