Jump to content

Obtain reference to auto-discovered class?


Go to solution Solved by softworkz,

Recommended Posts

Posted

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
Posted

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)

 

Posted

Perfect, thank you! I did not want to use static singletons.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...