示例#1
0
        static void Main(string[] args)
        {
            var logger  = new ConsoleLogger();
            var options = new Options();

            if (Parser.Default.ParseArguments(args, options))
            {
                try
                {
                    var indexer    = new DefaultIndexer();
                    var json       = File.ReadAllText(options.BatchPath);
                    var jobs       = JsonConvert.DeserializeObject <Job[]>(json);
                    var container  = new DefaultContainer(indexer, logger, null);
                    var staticSite = new StaticSite(container);
                    var publish    = staticSite.PublishAsync <Metadata>(jobs);

                    Task.WaitAll(publish);
                }
                catch (Exception e)
                {
                    logger.Log(string.Format("Error during publish '{0}'", e.InnerException.Message));
                }
            }
            else
            {
                logger.Log("Unable to parse arguments");
            }
        }
示例#2
0
        private int CreateIndexOfAlice()
        {
            var sourcePath        = TestHelper.GetPathToSystemTestData(m_BookFolderName);
            var allowedExtensions = new List <string> {
                ".htm"
            };
            int numberOfFiles = 0;

            using (var indexer = new DefaultIndexer(m_IndexFolder, sourcePath, allowedExtensions))
            {
                indexer.IndexerProcessFile += (sender, args) =>
                {
                    Debug.WriteLine("Processed file: {0}", args.FileName);
                    numberOfFiles++;
                };

                var task = indexer.CreateIndex();
                task.Wait();
            }

            return(numberOfFiles);
        }