public void TestInit()
        {
            var preProcessor = new PreProcessorService();
            var mediator     = new Mediator.Mediators.Mediator(preProcessor);

            mediator.Register(new IMessageHandler[]
            {
                new CommandReceiver(), new EventListener(), new OtherEventListener(),
                new RequestHandler()
            }, new IMessageHandlerAsync[]
            {
                new AsyncCommandReceiver(), new AsyncEventListener(), new OtherAsyncEventListener(),
                new AsyncRequestHandler()
            });
            _mediator = mediator;

            var altMediator = new Mediator.Mediators.Mediator(preProcessor);

            altMediator.Register(new IMessageHandler[]
            {
                new AlternateCommandReceiver(), new OtherAlternateCommandReceiver(),
                new EventListener(), new OtherEventListener(),
                new RequestWithSeveralHandlersHandler(), new OtherRequestWithSeveralHandlersHandler()
            }, new IMessageHandlerAsync[]
            {
                new AlternateAsyncCommandReceiver(), new OtherAlternateAsyncCommandReceiver(),
                new AsyncEventListener(), new OtherAsyncEventListener(),
                new RequestWithSeveralHandlersAsyncHandler(), new OtherRequestWithSeveralHandlersAsyncHandler()
            });
            _altMediator = altMediator;
        }
        public void ReGeneratePages()
        {
            var session = SessionFactory.Create();
            var repos = new PageTreeRepository(session);
            var pageRepos = new PageRepository(session);
            var locator = new Mock<IServiceLocator>();
            locator.Setup(x => x.ResolveAll<IPostLoadProcessor>()).Returns(new IPostLoadProcessor[] { new ChildPageSection(pageRepos) });

            locator.Setup(x => x.ResolveAll<ITextProcessor>()).Returns(new ITextProcessor[]
                                                                           {
                                                                               new MarkdownParser(),
                                                                               new WikiLinkProcessor(repos)
                                                                           });
            locator.Setup(x => x.ResolveAll<IHtmlProcessor>()).Returns(new IHtmlProcessor[] { new HeadingProcessor() });
            var pre = new PreProcessorService(locator.Object);

            var user = new UserRepository(session).GetOrCreate("BA84194", "Jonas Gauffin");
            var myIdentity = new WikiIdentity(user);
            Thread.CurrentPrincipal = new WikiPrinicpal(myIdentity);

            using (var transaction = session.BeginTransaction())
            {
                foreach (var page in pageRepos.FindAll())
                {
                    var ctx = new PreProcessorContext(page, page.RawBody);
                    pre.Invoke(ctx);
                    page.SetBody(ctx, "Changed to relative links", pageRepos);
                }

                transaction.Commit();
            }
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            var          fileReaderService    = new FileReaderService();
            var          videoRepository      = new VideoRepository();
            var          preProcessorService  = new PreProcessorService();
            const string downloadedTorretPath = "D:\\Downloads\\TorrentDay";

            var preProcessor = new PreProcessor(videoRepository, downloadedTorretPath, preProcessorService, fileReaderService);

            preProcessor.Start();

            Console.WriteLine("Press any key to exit");
            Console.ReadLine();
        }
Exemple #4
0
        public void TestInit()
        {
            var preProcessor = new PreProcessorService();
            var mediator     = new Mediator.Mediators.Mediator(preProcessor);

            mediator.Register(new IMessageHandler[]
            {
                new CommandReceiver(), new EventListener(), new OtherEventListener(),
                new RequestHandler()
            }, new IMessageHandlerAsync[]
            {
                new AsyncCommandReceiver(), new AsyncEventListener(), new OtherAsyncEventListener(),
                new AsyncRequestHandler()
            });
            _eventCollector =
                new EventCollectorFactory(mediator);
        }
        public void SimpleTest()
        {
            var allVideos = new List <Video>
            {
                new Video
                {
                    Title     = "Some Random Video",
                    EpisodeNr = 17,
                    SeasonNr  = 01,
                    Path      = "D:\\MyPath\\Some.Random.Video.mkv"
                },
                new Video
                {
                    Title     = "Another Random Video",
                    EpisodeNr = 15,
                    SeasonNr  = 03,
                    Path      = "D:\\MyPath\\Another.Random.Video.mkv"
                },
                new Video
                {
                    Title     = "Last Random Video",
                    EpisodeNr = 05,
                    SeasonNr  = 01,
                    Path      = "D:\\MyPath\\last.Random.Video.mkv"
                }
            };

            var oldVideo = new List <Video>
            {
                new Video
                {
                    Title     = "Last Random Video",
                    EpisodeNr = 05,
                    SeasonNr  = 01,
                    Path      = "D:\\MyPath\\last.Random.Video.mkv"
                }
            };

            var preProcessorService = new PreProcessorService();

            var newFiles = preProcessorService.GetNewVidosFromAllVideos(allVideos, oldVideo);

            Assert.AreEqual(2, newFiles.Count);
            Assert.AreEqual(newFiles[0], allVideos[0]);
            Assert.AreEqual(newFiles[1], allVideos[1]);
        }
        public void Generate()
        {
            var session = SessionFactory.Create();
            var repos = new PageTreeRepository(session);
            var pageRepos = new PageRepository(session);
            var locator = new Mock<IServiceLocator>();
            locator.Setup(x => x.ResolveAll<IPostLoadProcessor>()).Returns(new IPostLoadProcessor[] { new ChildPageSection(pageRepos) });

            locator.Setup(x => x.ResolveAll<ITextProcessor>()).Returns(new ITextProcessor[]
                                                                           {
                                                                               new MarkdownParser(),
                                                                               new WikiLinkProcessor(repos)
                                                                           });
            locator.Setup(x => x.ResolveAll<IHtmlProcessor>()).Returns(new IHtmlProcessor[] { new HeadingProcessor() });
            var pre = new PreProcessorService(locator.Object);


            var service = new OneDocService(repos, pre, new ImageRepository(session), new PostLoadProcessService(locator.Object));
            service.GenerateHTML("C:\\temp\\html\\working\\",
                                 new StreamWriter(new FileStream("C:\\temp\\html\\wiki.html", FileMode.Create)));
        }