I’m registering some ServiceTypes and want to be able to have a default implementation of the service, with a possibility to override entire class or specific methods.
Tried an abstract class, but this cannot be registered.
Tried an ‘default’ implementation of the abstract class, but can only get that implementation, no other class that implements the same interface.
Tried an normal class with virtual methods, but can only get that implementation, no other class that implements the same interface.
The abstract class or the interface should be the service type
[Service(ServiceType = typeof(A))]
public abstract class A {}
Create an implementation that inherit the abstract class or interface. This class will automatic be found during application initialization.
public class AImpl : A {}
To let another implementation be used before the AImpl you need to add the service attribute on the default implementation and set the FallbackService = true, that will tell the registration process that the implementation should be used if no other implementations is found.
[Service(FallbackService = true)]
public class AImpl : A {}
public class ASuperImpl : A {}
If you build an extension and have a contract that need to be implemented in the project you can add the RequireServiceImplementationAttribute on the service registration and if no registered service is found the application will not start.
[Service(ServiceType = typeof(A))]
[RequireServiceImplementation]
public abstract class A {}
You haven’t the assembly registered as ignore for plugins? This setting can also be set with the assembly attribute AssemblyLoading.
Another possibility is that you missed one assembly redirects in the configuration file, this is needed when different components using the same component with different version numbers.