public static void RegisterForSettingsChange(string settingName, EventHandler functionToCallOnChange, ref EventHandler functionThatWillBeCalledToUnregisterEvent) { if (!functionsToCallOnChange.ContainsKey(settingName)) { functionsToCallOnChange.Add(settingName, new RootedObjectEventHandler()); } RootedObjectEventHandler rootedEvent = functionsToCallOnChange[settingName]; rootedEvent.RegisterEvent(functionToCallOnChange, ref functionThatWillBeCalledToUnregisterEvent); }
public LibraryProviderSQLite(PrintItemCollection baseLibraryCollection, Action <LibraryProvider> setCurrentLibraryProvider, LibraryProvider parentLibraryProvider, string visibleName) : base(parentLibraryProvider, setCurrentLibraryProvider) { this.Name = visibleName; if (baseLibraryCollection == null) { baseLibraryCollection = GetRootLibraryCollection().Result; } this.baseLibraryCollection = baseLibraryCollection; LoadLibraryItems(); ItemAdded.RegisterEvent(DatabaseFileChange, ref unregisterEvents); }
public LibraryProviderSQLite(PrintItemCollection callerSuppliedCollection, Action <LibraryProvider> setCurrentLibraryProvider, LibraryProvider parentLibraryProvider, string visibleName) : base(parentLibraryProvider, setCurrentLibraryProvider) { this.Name = visibleName; // Lock ensures that SQLite providers initialized near the same time from different threads (which has been observed during debug) // will run in a serial fashion and only one instance will construct and assign to .baseLibraryCollection lock (initializingLock) { // Use null coalescing operator to assign either the caller supplied collection or if null, the root library collection this.baseLibraryCollection = callerSuppliedCollection ?? GetRootLibraryCollection(); } LoadLibraryItems(); ItemAdded.RegisterEvent(DatabaseFileChange, ref unregisterEvents); }
public LibraryProviderSelector(Action <LibraryProvider> setCurrentLibraryProvider, bool includeQueueLibraryProvider) : base(null, setCurrentLibraryProvider) { 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(); }