Exemplo n.º 1
0
        internal ItemsWatcher ItemsWatcher()
        {
            ItemsWatcher watcher = new ItemsWatcher();

            _itemsWatchers.Add(watcher);
            return(watcher);
        }
Exemplo n.º 2
0
        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);
            }
        }