Looking for some help with a blocker I'm having on my application.
For some context, this is a follow up to another question I've done: C# Validate that generic type extends generic abstract class with type parameters
Regarding the issue, on my project, the overall structure is the following:
public abstract class AbstractPlugin<TSignatureFile, TLoadedFile> :
IPlugin<TSignatureFile, TLoadedFile>
where TSignatureFile : IFileSignature
where TLoadedFile : LoadedFile { }
public interface IPlugin<out TSignatureFile, TLoadedFile>
where TSignatureFile : IFileSignature
where TLoadedFile : LoadedFile { }
public class MyPlugin : AbstractPlugin<MyPluginFileSignature, MyPluginFile { }
public class MyPluginFileSignature : IFileSignature { }
public class MyPluginFile : LoadedFile { }
This "MyPlugin is loaded from an external DLL where I create an Instance using:
var result = Activator.CreateInstance(type, notificationCallBack);
"notificationCallBack" is a constructor parameter.
The issue I'm having is that even though checking everything in terms of the type, what implements, etc it looks good, if I try to cast this "result" object to "IPlugin<IFileSignature, LoadedFile>" it fails the cast.
From my prespective this should work, as the instanciated object respects and implements this interface.
Could you please shed me some light on the subject, this is in a way blocking me from proceding further :(
Thanks