Protected 86 Posted September 9, 2024 Posted September 9, 2024 This is probably a really basic novice issue, but how might one obtain a reference to a server entry point or adjacent shared instance from service endpoint implementations? I need (or at least very strongly want) to inherit from BaseApiService, so I can't use inheritance. Must I use a singleton/static instance, or is there a facility in Emby for accessing the references of the auto-discovered instances, or a reference to the Plugin class of the containing plugin? So far I haven't been able to find out from the documentation.
Solution softworkz 5066 Posted September 10, 2024 Solution Posted September 10, 2024 You cannot register singleton instances yourself. You can find your own plugin in the list of plugins here: Emby SDK Reference: IApplicationHost.Plugins (for example using .OfType<YourPluginType>() ) This is the recommended way for all your code to get hold of something static: Using the plugin instance as common "anchor point". Please do not use static variables for this, but the method above to get it. You can get singletons as well as dynamically constructed objects via: Emby SDK Reference: IApplicationHost.Resolve<T>() (an endpoint implementation/API service is always constructed dynamically when needed)
Protected 86 Posted September 10, 2024 Author Posted September 10, 2024 Perfect, thank you! I did not want to use static singletons.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now