Here's a basic structure for a Monogame project making use of the ASP.NET Core HostedService technologies.
This lets you easily make use of DI within your game, but also include pluggable architecture.
- Program.cs - The entrypoint to your application. Uses dotnet core's CreateDefaultBuilder to make the DI setup easier.
- Worker.cs - The main game service. Handles the buildup/teardown of the the game class.
- ServiceCollectionExtensions.cs - A collection of extension methods to set up base DI defs and allow for adding plugins.
- IGame.cs - An interface that defines the layout of the main Game class. Implemented by your game class. Ideally should include all the Properties/Methods/Events of the base Game classs.
- ExampleGame.cs - An example of how to use the IGame interface.
- IStartupProvider.cs - An interface that defines how your plugin defines its DI and (possibly) additiona HostedServices.
- ExampleStartupProvider.cs - An example of how to use IStartupProvider so MEF detects it. Put the DLL in your executable directory and your program will automatically detect it and load it.