Skip to content

Instantly share code, notes, and snippets.

@dhindrik
Created June 1, 2022 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhindrik/9108947cbe736ba6b4f1abe295dd211c to your computer and use it in GitHub Desktop.
Save dhindrik/9108947cbe736ba6b4f1abe295dd211c to your computer and use it in GitHub Desktop.
// Option 1
foreach (var viewModel in assembly.DefinedTypes.Where(e => e.IsSubclassOf(typeof(ViewModel))))
{
builder.Services.AddTransient(viewModel.GetType());
}
foreach (var view in assembly.DefinedTypes.Where(e => e.IsSubclassOf(typeof(Views.View))))
{
builder.Services.AddTransient(view.GetType());
}
// Option 2
builder.Services.AddTransient<LoadingViewModel>();
builder.Services.AddTransient<LoadingView>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment