Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document ITypeFinder #12998

Open
hikalkan opened this issue Jun 14, 2022 · 1 comment
Open

Document ITypeFinder #12998

hikalkan opened this issue Jun 14, 2022 · 1 comment
Assignees
Milestone

Comments

@hikalkan
Copy link
Member

hikalkan commented Jun 14, 2022

ITypeFinder can be used to discover types in the application, even before the dependency injection registration phase completed.

Example usage:

public override void PreConfigureServices(ServiceConfigurationContext context)
{
    var typeFinder = context.Services.GetSingletonInstance<ITypeFinder>();
    foreach (var type in typeFinder.Types)
    {
        if (type.IsAssignableTo<Control>())
        {
            // do something...
        }
    }
}

After the dependency injection phase completed, you can inject ITypeFinder into any class.

ITypeFinder makes it easy to find all types of the application without manually searching all the assemblies. It also makes the assembly search only once, so it is optimized.

There is also IAssemblyFinder to get all assemblies in the application.

Note that assemblies and types are returned only for the assemblies with AbpModule classes.

@hikalkan hikalkan added this to the backlog milestone Jun 14, 2022
@hikalkan hikalkan self-assigned this Jun 14, 2022
@hikalkan
Copy link
Member Author

I added an extension method, so we can get it using context.Services.GetTypeFinder() method.

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

No branches or pull requests

1 participant