1

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?

Steven
  • 166,672
  • 24
  • 332
  • 435
Auguste Leroi
  • 215
  • 1
  • 7

1 Answers1

1

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.

ioan
  • 722
  • 4
  • 12