public SourceWatcherService(IHostingEnvironment env, IConfiguration configuration, IInvokerCacheService invokerCacheService, IGistCacheService gistCacheService, ISearchService searchService)
        {
            SourceWatcherType watcherType;

            if (env.IsProduction())
            {
                string watcherTypeRegistryValue = Registry.GetValue(RegistryConstants.SourceWatcherRegistryPath, RegistryConstants.WatcherTypeKey, 0).ToString();
                if (!Enum.TryParse <SourceWatcherType>(watcherTypeRegistryValue, out watcherType))
                {
                    throw new NotSupportedException($"Source Watcher Type : {watcherTypeRegistryValue} not supported.");
                }
            }
            else
            {
                watcherType = Enum.Parse <SourceWatcherType>(configuration[$"SourceWatcher:{RegistryConstants.WatcherTypeKey}"]);
            }

            switch (watcherType)
            {
            case SourceWatcherType.LocalFileSystem:
                _watcher = new LocalFileSystemWatcher(env, configuration, invokerCacheService, gistCacheService);
                break;

            case SourceWatcherType.Github:
                IGithubClient githubClient = new GithubClient(env, configuration);
                _watcher = new GitHubWatcher(env, configuration, invokerCacheService, gistCacheService, githubClient, searchService);
                break;

            default:
                throw new NotSupportedException("Source Watcher Type not supported");
            }
        }
Пример #2
0
        public WikiSite(WikiConfig config, MasterRepository masterRepository, ISourceWatcher sourceWatcher, IPageCache pageCache)
        {
            wikiConfig = config;

            repository = masterRepository;

            watcher = sourceWatcher;
            generator = new WikiGenerator(wikiConfig.Convertor, wikiConfig.RootWikiPath, pageCache);

            siteGeneratorScheduler = new EventLoopScheduler(threadStart => new Thread(threadStart) { Name = "SiteGenerator" });
        }
Пример #3
0
        public WikiSite(WikiConfig config, MasterRepository masterRepository, ISourceWatcher sourceWatcher, IPageCache pageCache)
        {
            wikiConfig = config;

            repository = masterRepository;

            watcher   = sourceWatcher;
            generator = new WikiGenerator(wikiConfig.Convertor, wikiConfig.RootWikiPath, pageCache);

            siteGeneratorScheduler = new EventLoopScheduler(threadStart => new Thread(threadStart)
            {
                Name = "SiteGenerator"
            });
        }