In MEF there is a export example like this:
[Export]
public static MenuBarDefinition MainMenuBar = new MenuBarDefinition();
Injectio does not support this operation, but we can implement it. Theoretically, by using the following code:
namespace Gemini.Modules.MainMenu
{
public static class MenuDefinitions
{
[RegisterSingleton<MenuDefinition>]
public static MenuDefinition MainMenuBar = new MenuBarDefinition();
}
}
we can then generate
global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAdd(
serviceCollection,
global::Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Scoped<global::Gemini.Framework.Menus.MenuBarDefinition>(_=>Gemini.Modules.MainMenu.MenuDefinitions.MainMenuBar)
);
Therefore, Injectio can extend the RegisterSingletonAttribute. This attribute can decorate fields and auto-properties. they must be public and static, and cannot be null.
In MEF there is a export example like this:
Injectio does not support this operation, but we can implement it. Theoretically, by using the following code:
we can then generate
Therefore, Injectio can extend the RegisterSingletonAttribute. This attribute can decorate fields and auto-properties. they must be public and static, and cannot be null.