I really like how one can override services in Kephas Framework by providing the OverridePriority attribute. However, I need that some services do not get overridden anymore, to prohibit that some external code from plugins override my security services. How can I do this?
The simplest answer is: provide the highest override priority for your service.
[OverridePriority(Priority.Highest)]
public class MyServiceImpl : IMyService {
// ...
}
However, there can be a problem if more than one service is registered with the highest priority, in which case an AmbiguousMatchException
is thrown. I mean, you should be in control of your code to avoid such cases. If you think that there is a chance that the application runtime loads a malevolent assembly, provide your own AppRuntime
service which may check the assemblies prior to their loading.
Check https://github.com/kephas-software/kephas/wiki/Application-Services#override-priority for more information about this topic.