Skip to content

AsSelfWithInterfaces = AsImplementedInterfaces+AsSelf right? #202

Description

@gitlsl
.AddClasses(classes => classes.AssignableTo<ISingletonService>().WithoutAttribute<NotInjectAttribute>())
        .AsImplementedInterfaces(x => x != typeof(ISingletonService))
        .AsSelf()
        .WithSingletonLifetime()    // A

.AddClasses(classes => classes.AssignableTo<ISingletonService>().WithoutAttribute<NotInjectAttribute>())
        .AsSelfWithInterfaces()
        .WithSingletonLifetime() //B

public class TestService2 : ISingletonService
{
    public TestService2()
    {
        Console.WriteLine("ctor2 in TestService ");
    }
}

            Console.WriteLine(provider.GetService<ISingletonService>().GetType().FullName);
            Console.WriteLine(provider.GetService<TestService2>().GetType().FullName);

beacause AsSelfWithInterfaces can not filter interface, so I seprate AsImplementedInterfaces+AsSelf
but code will print 2 times "ctor2 in TestService " in scense A , print 1 time in scense B

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions