chef 3745 Posted May 3, 2020 Share Posted May 3, 2020 Hi, I was just wondering if it is possible to register a new interface to implement in emby's factory method? I hope that my question makes sense. I don't want to 'new-up' an object with a bunch of parameters in my code. I would rather register the interface with, whichever factory emby is using to new up its Interfaces with all the other ones. I wish I knew exactly what to name it, but I'm not sure because... not a pro... yet. For example, when a 'ServerEntryPoint' class is created, you can pass in a bunch of interfaces into it's constructor and use them. Those Interfaces are references to constructed classes, which would have had to have been instantiated at some point. Add to that factory method...? Currently, I have built an 'EmbyControllerUtility' which takes in a whole bunch of those interfaces. But that means that when it is instantiated, it looks like this: private ILibraryManager LibraryManager { get; } private IUserManager UserManager { get; } private ITVSeriesManager TvSeriesManager { get; } private ISessionManager SessionManager { get; } private IUserDataManager UserDataManager { get; } public EmbyControllerUtility(ILibraryManager libMan, IUserManager user, ITVSeriesManager tvMan, ISessionManager sesMan, IUserDataManager userData) { LibraryManager = libMan; UserManager = user; TvSeriesManager = tvMan; SessionManager = sesMan; UserDataManager = userData; } new EmbyControllerUtility(LibraryManager, UserManager, TvSeriesManager, SessionManager, UserDataManager); which ends up getting called from a class with a constructor which looks huge! protected IntentHandler(ILibraryManager libraryManager, ISessionManager sessionManager, IJsonSerializer jsonSerializer, IHttpClient client, IUserManager userManager, ITVSeriesManager tvSeriesManager, IUserDataManager userData) : base(jsonSerializer, client) { SessionManager = sessionManager; LibraryManager = libraryManager; UserManager = userManager; TvSeriesManager = tvSeriesManager; UserDataManager = userData; JsonSerializer = jsonSerializer; Client = client; EmbyController = new EmbyControllerUtility(LibraryManager, UserManager, TvSeriesManager, SessionManager, UserDataManager); } // ReSharper disable TooManyDependencies // ReSharper disable TooManyArguments // ReSharper disable TooManyChainedReferences The objects in the constructor could be cut back by half, if "EmbyControllUtility' interface could be instantiated out side the scope of the code, and an interface could be passed along. I think... ... Link to comment Share on other sites More sharing options...
chef 3745 Posted May 3, 2020 Author Share Posted May 3, 2020 The best thing to do in this situation is to create another IServerEntryPoint implementation. Found here: https://github.com/MediaBrowser/Emby/wiki/Automatic-Type-Discovery IServerEntryPoint Keep in mind you can have as many of these as you need, allowing you to break larger plugins into smaller pieces. Link to comment Share on other sites More sharing options...
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