public void WatchItems <TypedItem>(IFolder folder, TypedItemEventHandler <TypedItem> handler, bool reportExisting) where TypedItem : IItem { if (!DebugOptions.GetOption(null, DebugOptions.WATCHER_ENABLED)) { return; } // Must have a ZPush folder to watch events. ZPushFolder zPushFolder = folder.ZPush; // Register the handlers ItemsWatcher watcher = zPushFolder.ItemsWatcher(); watcher.ItemEvent += (item) => { if (item is TypedItem) { handler((TypedItem)item); } }; // Report existing if requested if (reportExisting) { zPushFolder.ReportExistingItems(handler); } }
public static bool IsEnabled(Type featureType) { bool defaultEnabled = !typeof(FeatureDisabled).IsAssignableFrom(featureType); return(DebugOptions.GetOption(GetFeatureName(featureType), defaultEnabled ? DebugOptions.ENABLED : DebugOptions.FEATURE_DISABLED_DEFAULT)); }
public FolderWatcher WatchFolder(FolderRegistration folder, FolderEventHandler handler, FolderEventHandler changedHandler = null, FolderEventHandler removedHandler = null) { if (!DebugOptions.GetOption(null, DebugOptions.WATCHER_ENABLED)) { return(null); } FolderWatcher watcher; if (!_folderWatchers.TryGetValue(folder, out watcher)) { watcher = new FolderWatcher(); _folderWatchers.TryAdd(folder, watcher); } watcher.Discovered += handler; if (changedHandler != null) { watcher.Changed += changedHandler; } if (removedHandler != null) { watcher.Removed += removedHandler; } // Check existing folders for events foreach (ZPushFolder existing in _allFolders) { if (folder.IsApplicable(existing.Folder)) { DispatchFolderEvent(folder, watcher, existing, EventKind.Discovered); } } return(watcher); }
public static ValueType GetOption <ValueType>(Type featureType, DebugOptions.Option <ValueType> option) { return(DebugOptions.GetOption(GetFeatureName(featureType), option)); }
public ValueType GetOption <ValueType>(DebugOptions.Option <ValueType> option) { return(DebugOptions.GetOption(Name, option)); }