VsixCommunity / Community.VisualStudio.Toolkit.DependencyInjection

Adds Dependency Injection tooling for the Community.VisualStudio.Toolkit
Other
14 stars 7 forks source link

Auto register commands #5

Closed StevenRasmussen closed 2 years ago

StevenRasmussen commented 2 years ago

This PR adds the ability to create commands that are instantiated by the DI container. What this does in practice is allow your constructors to inject other services into them. It also allows you to control the lifetime of the command, ie Singleton or Scoped.

This also adds a helper extension method that allows you to register all your commands in an assembly very easily:

services.RegisterCommands(ServiceLifetime.Singleton); // Registers your commands in the calling assembly
services.RegisterCommands(ServiceLifetime.Scoped, Assembly1, Assembly2); // Registers your commands in the specified assemblies
madskristensen commented 2 years ago

Awesome!!