当前位置: 首页>>代码示例>>C#>>正文


C# Converters.MarkupConverter类代码示例

本文整理汇总了C#中Roadkill.Core.Converters.MarkupConverter的典型用法代码示例。如果您正苦于以下问题:C# MarkupConverter类的具体用法?C# MarkupConverter怎么用?C# MarkupConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MarkupConverter类属于Roadkill.Core.Converters命名空间,在下文中一共展示了MarkupConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_Replace_Known_Tokens_When_Logged_In_As_Admin

		public void Should_Replace_Known_Tokens_When_Logged_In_As_Admin()
		{
			// Arrange
			string menuMarkup = "* %categories%\r\n\r\n%allpages%\r\n%mainpage%\r\n%newpage%\r\n%managefiles%\r\n%sitesettings%\r\n";
			string expectedHtml = "<ul><li><a href=\"/pages/alltags\">Categories</a></li></ul>" +
								  "<a href=\"/pages/allpages\">All pages</a>" +
								  "<a href=\"/\">Main Page</a>" +
								  "<a href=\"/pages/new\">New page</a>" +
								  "<a href=\"/filemanager\">Manage files</a>" +
								  "<a href=\"/settings\">Site settings</a>";

			RepositoryMock repository = new RepositoryMock();
			repository.SiteSettings = new SiteSettings();
			repository.SiteSettings.MarkupType = "Markdown";
			repository.SiteSettings.MenuMarkup = menuMarkup;

			UserContextStub userContext = new UserContextStub();
			userContext.IsAdmin = true;
			userContext.IsLoggedIn = true;

			ApplicationSettings applicationSettings = new ApplicationSettings();
			applicationSettings.Installed = true;
			CacheMock cache = new CacheMock();
			SiteCache siteCache = new SiteCache(applicationSettings, cache);

			MarkupConverter converter = new MarkupConverter(applicationSettings, repository, _pluginFactory);
			MenuParser parser = new MenuParser(converter, repository, siteCache, userContext);

			// Act
			string actualHtml = parser.GetMenu();

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
		}
开发者ID:35e8,项目名称:roadkill,代码行数:34,代码来源:MenuParserTests.cs

示例2: MenuParser

 public MenuParser(MarkupConverter markupConverter, IRepository repository, SiteCache siteCache, IUserContext userContext)
 {
     _markupConverter = markupConverter;
     _repository = repository;
     _siteCache = siteCache;
     _userContext = userContext;
 }
开发者ID:NaseUkolyCZ,项目名称:roadkill,代码行数:7,代码来源:MenuParser.cs

示例3: PageViewModel

        public PageViewModel(PageContent pageContent, MarkupConverter converter)
        {
            if (pageContent == null)
                throw new ArgumentNullException("pageContent");

            if (pageContent.Page == null)
                throw new ArgumentNullException("pageContent.Page");

            if (converter == null)
                throw new ArgumentNullException("converter");

            Id = pageContent.Page.Id;
            Title = pageContent.Page.Title;
            PreviousTitle = pageContent.Page.Title;
            CreatedBy = pageContent.Page.CreatedBy;
            CreatedOn = pageContent.Page.CreatedOn;
            IsLocked = pageContent.Page.IsLocked;
            ModifiedBy = pageContent.Page.ModifiedBy;
            ModifiedOn = pageContent.Page.ModifiedOn;
            RawTags = pageContent.Page.Tags;
            Content = pageContent.Text;
            VersionNumber = pageContent.VersionNumber;

            PageHtml pageHtml = converter.ToHtml(pageContent.Text);
            ContentAsHtml = pageHtml.Html;
            IsCacheable = pageHtml.IsCacheable;
            PluginHeadHtml = pageHtml.HeadHtml;
            PluginFooterHtml = pageHtml.FooterHtml;
            PluginPreContainer = pageHtml.PreContainerHtml;
            PluginPostContainer = pageHtml.PostContainerHtml;

            CreatedOn = DateTime.SpecifyKind(CreatedOn, DateTimeKind.Utc);
            ModifiedOn = DateTime.SpecifyKind(ModifiedOn, DateTimeKind.Utc);
            AllTags = new List<TagViewModel>();
        }
开发者ID:NaseUkolyCZ,项目名称:roadkill,代码行数:35,代码来源:PageViewModel.cs

示例4: MenuParser

		public MenuParser(MarkupConverter markupConverter, ISettingsRepository settingsRepository, SiteCache siteCache, IUserContext userContext)
		{
			_markupConverter = markupConverter;
			_settingsRepository = settingsRepository;
			_siteCache = siteCache;
			_userContext = userContext;
		}
开发者ID:RyanGroom,项目名称:roadkill,代码行数:7,代码来源:MenuParser.cs

示例5: Images_Should_Support_Dimensions

        public void Images_Should_Support_Dimensions()
        {
            // Arrange
            Page page = new Page() { Id = 1, Title = "My first page" };

            RepositoryMock repositoryStub = new RepositoryMock();
            repositoryStub.AddNewPage(page, "My first page", "admin", DateTime.UtcNow);
            repositoryStub.SiteSettings = new SiteSettings() { MarkupType = "Markdown" };

            ApplicationSettings settings = new ApplicationSettings();
            settings.Installed = true;
            settings.UpgradeRequired = false;

            MarkupConverter converter = new MarkupConverter(settings, repositoryStub, _pluginFactory);

            string markdownText = "Here is an image:![Image](/Image1.png) \n\n" +
                                  "And another with equal dimensions ![Square](/Image1.png =250x) \n\n" +
                                  "And this one is a rectangle ![Rectangle](/Image1.png =250x350)";

            string expectedHtml = "<p>Here is an image:<img src=\"/Attachments/Image1.png\" border=\"0\" alt=\"Image\" width=\"\" height=\"\" /> </p>\n\n" +
                                    "<p>And another with equal dimensions <img src=\"/Attachments/Image1.png\" border=\"0\" alt=\"Square\" width=\"250px\" height=\"\" /> </p>\n\n" +
                                    "<p>And this one is a rectangle <img src=\"/Attachments/Image1.png\" border=\"0\" alt=\"Rectangle\" width=\"250px\" height=\"350px\" /></p>\n";

            // Act
            string actualHtml = converter.ToHtml(markdownText);

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
开发者ID:NaseUkolyCZ,项目名称:roadkill,代码行数:29,代码来源:MarkdownTests.cs

示例6: MocksAndStubsContainer

        /// <summary>
        /// Creates a new instance of MocksAndStubsContainer.
        /// </summary>
        /// <param name="useCacheMock">The 'Roadkill' MemoryCache is used by default, but as this is static it can have problems with 
        /// the test runner unless you clear the Container.MemoryCache on setup each time, but then doing that doesn't give a realistic 
        /// reflection of how the MemoryCache is used inside an ASP.NET environment.</param>
        public MocksAndStubsContainer(bool useCacheMock = false)
        {
            ApplicationSettings = new ApplicationSettings();
            ApplicationSettings.Installed = true;
            ApplicationSettings.AttachmentsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "attachments");

            // Cache
            MemoryCache = useCacheMock ? new CacheMock() : CacheMock.RoadkillCache;
            ListCache = new ListCache(ApplicationSettings, MemoryCache);
            SiteCache = new SiteCache(ApplicationSettings, MemoryCache);
            PageViewModelCache = new PageViewModelCache(ApplicationSettings, MemoryCache);

            // Repository
            Repository = new RepositoryMock();
            Repository.SiteSettings = new SiteSettings();
            Repository.SiteSettings.MarkupType = "Creole";

            PluginFactory = new PluginFactoryMock();
            MarkupConverter = new MarkupConverter(ApplicationSettings, Repository, PluginFactory);

            // Dependencies for PageService. Be careful to make sure the class using this Container isn't testing the mock.
            SettingsService = new SettingsService(ApplicationSettings, Repository);
            UserService = new UserServiceMock(ApplicationSettings, Repository);
            UserContext = new UserContext(UserService);
            SearchService = new SearchServiceMock(ApplicationSettings, Repository, PluginFactory);
            SearchService.PageContents = Repository.PageContents;
            SearchService.Pages = Repository.Pages;
            HistoryService = new PageHistoryService(ApplicationSettings, Repository, UserContext, PageViewModelCache, PluginFactory);

            PageService = new PageService(ApplicationSettings, Repository, SearchService, HistoryService, UserContext, ListCache, PageViewModelCache, SiteCache, PluginFactory);

            // EmailTemplates
            EmailClient = new EmailClientMock();
        }
开发者ID:Kiresorg,项目名称:roadkill,代码行数:40,代码来源:MocksAndStubsContainer.cs

示例7: Internal_Links_Should_Resolve_With_Id

        public void Internal_Links_Should_Resolve_With_Id()
        {
            // Bug #87

            // Arrange
            Page page = new Page() { Id = 1, Title = "My first page"};

            RepositoryMock repositoryStub = new RepositoryMock();
            repositoryStub.AddNewPage(page, "My first page", "admin", DateTime.UtcNow);
            repositoryStub.SiteSettings = new SiteSettings() { MarkupType = "Markdown" };

            ApplicationSettings settings = new ApplicationSettings();
            settings.Installed = true;
            settings.UpgradeRequired = false;

            UrlResolverMock resolver = new UrlResolverMock();
            resolver.InternalUrl = "blah";
            MarkupConverter converter = new MarkupConverter(settings, repositoryStub, _pluginFactory);
            converter.UrlResolver = resolver;

            string markdownText = "[Link](My-first-page)";
            string invalidMarkdownText = "[Link](My first page)";

            // Act
            string expectedHtml = "<p><a href=\"blah\">Link</a></p>\n";
            string expectedInvalidLinkHtml = "<p>[Link](My first page)</p>\n";

            string actualHtml = converter.ToHtml(markdownText);
            string actualHtmlInvalidLink = converter.ToHtml(invalidMarkdownText);

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
            Assert.That(actualHtmlInvalidLink, Is.EqualTo(expectedInvalidLinkHtml));
        }
开发者ID:Kiresorg,项目名称:roadkill,代码行数:34,代码来源:MarkdownTests.cs

示例8: Code_Blocks_Should_Allow_Quotes

        public void Code_Blocks_Should_Allow_Quotes()
        {
            // Issue #82
            // Arrange
            Page page = new Page() { Id = 1, Title = "My first page" };

            RepositoryMock repositoryStub = new RepositoryMock();
            repositoryStub.AddNewPage(page, "My first page", "admin", DateTime.UtcNow);
            repositoryStub.SiteSettings = new SiteSettings() { MarkupType = "Markdown" };

            ApplicationSettings settings = new ApplicationSettings();
            settings.Installed = true;
            settings.UpgradeRequired = false;

            MarkupConverter converter = new MarkupConverter(settings, repositoryStub, _pluginFactory);

            string markdownText = "Here is some `// code with a 'quote' in it and another \"quote\"`\n\n" +
                "    var x = \"some tabbed code\";\n\n"; // 2 line breaks followed by 4 spaces (tab stop) at the start indicates a code block

            string expectedHtml = "<p>Here is some <code>// code with a 'quote' in it and another \"quote\"</code></p>\n\n" +
                                "<pre><code>var x = \"some tabbed code\";\n" +
                                "</code></pre>\n";

            // Act
            string actualHtml = converter.ToHtml(markdownText);

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
开发者ID:NaseUkolyCZ,项目名称:roadkill,代码行数:29,代码来源:MarkdownTests.cs

示例9: HomeController

		public HomeController(ApplicationSettings settings, UserServiceBase userManager, MarkupConverter markupConverter,
			PageService pageService, SearchService searchService, IUserContext context, SettingsService settingsService)
			: base(settings, userManager, context, settingsService) 
		{
			_markupConverter = markupConverter;
			_searchService = searchService;
			PageService = pageService;
		}
开发者ID:LocalGovDigital,项目名称:pipeline,代码行数:8,代码来源:HomeController.cs

示例10: PageHistoryService

		public PageHistoryService(ApplicationSettings settings, IRepository repository, IUserContext context,
			PageViewModelCache pageViewModelCache, IPluginFactory pluginFactory)
			: base(settings, repository)
		{
			_markupConverter = new MarkupConverter(settings, repository, pluginFactory);
			_context = context;
			_pageViewModelCache = pageViewModelCache;
		}
开发者ID:LocalGovDigital,项目名称:pipeline,代码行数:8,代码来源:PageHistoryService.cs

示例11: PageHistoryService

		public PageHistoryService(ApplicationSettings settings, ISettingsRepository settingsRepository, IPageRepository pageRepository, IUserContext context, 
			PageViewModelCache pageViewModelCache, IPluginFactory pluginFactory)
		{
			_markupConverter = new MarkupConverter(settings, settingsRepository, pageRepository, pluginFactory);
			_context = context;
			_pageViewModelCache = pageViewModelCache;

			SettingsRepository = settingsRepository;
			PageRepository = pageRepository;
		}
开发者ID:RyanGroom,项目名称:roadkill,代码行数:10,代码来源:PageHistoryService.cs

示例12: Setup

		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_pluginFactory = _container.PluginFactory;
			_appSettings = _container.ApplicationSettings;
			_appSettings.Installed = true;
			_repository = _container.Repository;
			_markupConverter = _container.MarkupConverter;
			_markupConverter.UrlResolver = new UrlResolverMock();
		}
开发者ID:35e8,项目名称:roadkill,代码行数:11,代码来源:PageViewModelTests.cs

示例13: parser_should_not_be_null_for_markuptypes

		public void parser_should_not_be_null_for_markuptypes()
		{
			// Arrange, act
			_settingsRepository.SiteSettings.MarkupType = "Creole";

			// Assert
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);
			Assert.NotNull(_markupConverter.Parser);

			_settingsRepository.SiteSettings.MarkupType = "Markdown";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);
			Assert.NotNull(_markupConverter.Parser);
		}
开发者ID:RyanGroom,项目名称:roadkill,代码行数:13,代码来源:MarkupConverterTests.cs

示例14: Setup

		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_applicationSettings.UseHtmlWhiteList = true;
			_applicationSettings.CustomTokensPath = Path.Combine(Settings.WEB_PATH, "App_Data", "customvariables.xml");

			_pluginFactory = _container.PluginFactory;
			_repository = _container.Repository;
			_markupConverter = _container.MarkupConverter;
			_markupConverter.UrlResolver = new UrlResolverMock();
		}
开发者ID:35e8,项目名称:roadkill,代码行数:13,代码来源:MarkupConverterTests.cs

示例15: RelService

 public RelService(ApplicationSettings settings, IRepository repository, SearchService searchService,
     PageHistoryService historyService, IUserContext context,
     ListCache listCache, PageViewModelCache pageViewModelCache, SiteCache sitecache, IPluginFactory pluginFactory)
     : base(settings, repository)
 {
     _searchService = searchService;
     _markupConverter = new MarkupConverter(settings, repository, pluginFactory);
     _historyService = historyService;
     _context = context;
     _listCache = listCache;
     _pageViewModelCache = pageViewModelCache;
     _siteCache = sitecache;
     _pluginFactory = pluginFactory;
 }
开发者ID:LocalGovDigital,项目名称:pipeline,代码行数:14,代码来源:RelService.cs


注:本文中的Roadkill.Core.Converters.MarkupConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。