public LibraryProviderSelector(Action<LibraryProvider> setCurrentLibraryProvider, bool includeQueueLibraryProvider) : base(null, setCurrentLibraryProvider) { currentInstance = this; this.includeQueueLibraryProvider = includeQueueLibraryProvider; this.Name = "Home".Localize(); LibraryRootNotice.RegisterEvent((sender, args) => { this.ReloadData(); }, ref unregisterEvents); ApplicationController.Instance.CloudSyncStatusChanged.RegisterEvent(CloudSyncStatusChanged, ref unregisterEvents); libraryProviderPlugins = new PluginFinder<LibraryProviderPlugin>(); ReloadData(); }
public LibraryProviderSelector(Action <LibraryProvider> setCurrentLibraryProvider, bool includeQueueLibraryProvider) : base(null, setCurrentLibraryProvider) { currentInstance = this; this.includeQueueLibraryProvider = includeQueueLibraryProvider; this.Name = "Home".Localize(); LibraryRootNotice.RegisterEvent((sender, args) => { this.ReloadData(); }, ref unregisterEvents); ApplicationController.Instance.CloudSyncStatusChanged.RegisterEvent(CloudSyncStatusChanged, ref unregisterEvents); libraryProviderPlugins = new PluginFinder <LibraryProviderPlugin>(); ReloadData(); }
public static async Task <LibraryProvider> GetLibraryFromLocator(List <ProviderLocatorNode> libraryProviderLocator) { LibraryProviderSelector selector = new LibraryProviderSelector(null, true); LibraryProvider lastProvider = null; if (libraryProviderLocator.Count > 1) { ProviderLocatorNode selectorNode = libraryProviderLocator[1]; foreach (ILibraryCreator libraryCreator in selector.libraryCreators) { if (libraryCreator.ProviderKey == selectorNode.Key) { // We found the right creatory, make the library and then iterate through it to get to the correct sub library lastProvider = libraryCreator.CreateLibraryProvider(null, null); for (int i = 2; i < libraryProviderLocator.Count; i++) { ProviderLocatorNode currentNode = libraryProviderLocator[i]; // wait for our current providre to finish loading while (lastProvider.CollectionCount == 0) { Thread.Sleep(100); } // now find the next sub provider and go to it for (int collectionIndex = 0; collectionIndex < lastProvider.CollectionCount; collectionIndex++) { PrintItemCollection collection = lastProvider.GetCollectionItem(collectionIndex); if (collection.Key == currentNode.Key) { lastProvider = lastProvider.GetProviderForCollection(collection); } } } } } } return(lastProvider); }
public static async Task<LibraryProvider> GetLibraryFromLocator(List<ProviderLocatorNode> libraryProviderLocator) { LibraryProviderSelector selector = new LibraryProviderSelector(null, true); LibraryProvider lastProvider = null; if (libraryProviderLocator.Count > 1) { ProviderLocatorNode selectorNode = libraryProviderLocator[1]; foreach (ILibraryCreator libraryCreator in selector.libraryCreators) { if (libraryCreator.ProviderKey == selectorNode.Key) { // We found the right creatory, make the library and then iterate through it to get to the correct sub library lastProvider = libraryCreator.CreateLibraryProvider(null, null); for (int i = 2; i < libraryProviderLocator.Count; i++) { ProviderLocatorNode currentNode = libraryProviderLocator[i]; // wait for our current providre to finish loading while (lastProvider.CollectionCount == 0) { Thread.Sleep(100); } // now find the next sub provider and go to it for (int collectionIndex = 0; collectionIndex < lastProvider.CollectionCount; collectionIndex++) { PrintItemCollection collection = lastProvider.GetCollectionItem(collectionIndex); if (collection.Key == currentNode.Key) { lastProvider = lastProvider.GetProviderForCollection(collection); } } } } } } return lastProvider; }