Exemple #1
0
        /// <summary>
        /// Initialize the Source Monitor as a Service Extension.
        /// </summary>
        /// <param name="config">configuration </param>
        /// <param name="serviceHost">service host which init the extension</param>
        public void Initialize(IConfiguration config, IServiceHost serviceHost)
        {
            if (config == null || serviceHost == null)
            {
                throw new InitializeParameterEmtyException("parameter can't be null for initialize");
            }

            _configSetting = config;
            _serviceHost   = serviceHost;

            WatchSourceCollection watchSourcese = this.ConfigurationSetting.GetConfiguationData <WatchSourceCollection>("");

            List <ISourceWatcher> watchers = _serviceHost.GetFunctionExtensions <ISourceWatcher>(ExtensionCategory.WatchingExtension);

            foreach (WatchSource source in watchSourcese)
            {
                watchers.ForEach(delegate(ISourceWatcher watcher)
                {
                    if (watcher.IsAcceptedSource(source))
                    {
                        watcher.Watching(source);

                        watcher.RegisterEvent(this.MonitorSourceChangedEventHandler);
                    }
                });
            }

            _serviceHost.RunInBackground(this);
        }
Exemple #2
0
        public void Running()
        {
            lock (_gate)
            {
                WatchSource source = _changedSourceQueue.Dequeue();

                List <IBookScanner> scanners = _serviceHost.GetFunctionExtensions <IBookScanner>(ExtensionCategory.ScanningExtension);

                foreach (IBookScanner scanner in scanners)
                {
                    if (scanner.IsAcceptedSource(source))
                    {
                        scanner.Scanning(source, this.MonitorFindBookEventHandler);
                        break;
                    }
                }
                ;
            }
        }