Dynamically Implementing Interfaces at Runtime
Good day all,
For a modding framework refactor/rework, we are implementing interface-based events, which can be defined by mods and will be loaded at runtime as well, ie:
and an event publisher will follow a pattern as follows:
The issue we have is that we support
So, I've been investigating using some combination of
I'd like to avoid having to
What are my options here? Because this is my goal in pseudo code:
Anyways, any help is appreciated.
For a modding framework refactor/rework, we are implementing interface-based events, which can be defined by mods and will be loaded at runtime as well, ie:
and an event publisher will follow a pattern as follows:
The issue we have is that we support
Lua scripting via MoonSharp, which includes events. This was here before and we have the legacy API which must be supported as follows:So, I've been investigating using some combination of
Linq.Expression and ExpandoObject or dynamic to dynamically construct a runtime proxy type that implements the interface but searching has been kind of a pain because all major examples are for either .NET Framework and don't work in .NET Core, or they're for Mocking/Testing and are answered using Moq, Castle or some other testing-targeted framework.I'd like to avoid having to
Emit an IL method dynamically. We have some of this already for dynamic hooking classes and maintain it has been a growing pain.What are my options here? Because this is my goal in pseudo code:
Anyways, any help is appreciated.