本文整理汇总了C#中Roadkill.Core.Configuration.ApplicationSettings类的典型用法代码示例。如果您正苦于以下问题:C# ApplicationSettings类的具体用法?C# ApplicationSettings怎么用?C# ApplicationSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationSettings类属于Roadkill.Core.Configuration命名空间,在下文中一共展示了ApplicationSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigurationTesterController
public ConfigurationTesterController(ApplicationSettings appSettings, IUserContext userContext, ConfigReaderWriter configReaderWriter, IActiveDirectoryProvider activeDirectoryProvider)
{
_applicationSettings = appSettings;
_userContext = userContext;
_configReaderWriter = configReaderWriter;
_activeDirectoryProvider = activeDirectoryProvider;
}
示例2: Setup
public void Setup()
{
_container = new MocksAndStubsContainer();
_applicationSettings = _container.ApplicationSettings;
_context = _container.UserContext;
_settingsRepository = _container.SettingsRepository;
_userRepository = _container.UserRepository;
_pageRepository = _container.PageRepository;
_settingsService = _container.SettingsService;
_userService = _container.UserService;
_pageCache = _container.PageViewModelCache;
_listCache = _container.ListCache;
_siteCache = _container.SiteCache;
_cache = _container.MemoryCache;
_container.ClearCache();
_pageService = _container.PageService;
_wikiImporter = new WikiImporterMock();
_pluginFactory = _container.PluginFactory;
_searchService = _container.SearchService;
// There's no point mocking WikiExporter (and turning it into an interface) as
// a lot of usefulness of these tests would be lost when creating fake Streams and zip files.
_wikiExporter = new WikiExporter(_applicationSettings, _pageService, _settingsRepository, _pageRepository, _userRepository, _pluginFactory);
_wikiExporter.ExportFolder = AppDomain.CurrentDomain.BaseDirectory;
_toolsController = new ToolsController(_applicationSettings, _userService, _settingsService, _pageService,
_searchService, _context, _listCache, _pageCache, _wikiImporter,
_pluginFactory, _wikiExporter);
}
示例3: 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();
}
示例4: shoulddeserializewhitelistfromgeneratedxmlfile
public void shoulddeserializewhitelistfromgeneratedxmlfile()
{
// Arrange
string whitelistFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "whitelistgenerated.xml");
ApplicationSettings settings = new ApplicationSettings();
settings.HtmlElementWhiteListPath = whitelistFile;
using (FileStream stream = new FileStream(whitelistFile, FileMode.Create, FileAccess.Write))
{
XmlSerializer serializer = new XmlSerializer(typeof(HtmlWhiteList));
List<HtmlElement> list = new List<HtmlElement>();
list.Add(new HtmlElement("blah", new string[] { "id", "class" }));
list.Add(new HtmlElement("test", new string[] { "href" }));
HtmlWhiteList whiteList = new HtmlWhiteList();
whiteList.ElementWhiteList = list;
serializer.Serialize(stream, whiteList);
}
string htmlFragment = "<test href=\"http://www.google.com\">link</test> <blah id=\"myid\" class=\"class1 class2\">somediv</blah><a href=\"test\">test</a>";
// Act
MarkupSanitizer sanitizer = new MarkupSanitizer(settings);
sanitizer.SetWhiteListCacheKey("ShouldDeserializeWhiteListFromGeneratedXmlFile");
string actual = sanitizer.SanitizeHtml(htmlFragment);
// Assert
string expected = "<test href=\"http://www.google.com\">link</test> <blah id=\"myid\" class=\"class1 class2\">somediv</blah>";
Assert.That(actual, Is.EqualTo(expected).IgnoreCase);
}
示例5: MockServiceLocator
private void MockServiceLocator()
{
var settings = new ApplicationSettings();
var configReader = new ConfigReaderWriterStub();
configReader.ApplicationSettings = settings;
var registry = new RoadkillRegistry(configReader);
var container = new Container(registry);
container.Configure(x =>
{
x.Scan(a => a.AssemblyContainingType<TestHelpers>());
x.For<IPageRepository>().Use(new PageRepositoryMock());
x.For<IUserContext>().Use(new UserContextStub());
});
LocatorStartup.Locator = new StructureMapServiceLocator(container, false);
DependencyResolver.SetResolver(LocatorStartup.Locator);
var all =
container.Model.AllInstances.OrderBy(t => t.PluginType.Name)
.Select(t => String.Format("{0}:{1}", t.PluginType.Name, t.ReturnedType.AssemblyQualifiedName));
Console.WriteLine(String.Join("\n", all));
}
示例6: Setup
public void Setup()
{
_container = new MocksAndStubsContainer();
_applicationSettings = _container.ApplicationSettings;
_applicationSettings.ConnectionString = "connstring";
_context = _container.UserContext;
_repository = _container.Repository;
_pluginFactory = _container.PluginFactory;
_settingsService = _container.SettingsService;
_userService = _container.UserService;
_historyService = _container.HistoryService;
_pageService = _container.PageService;
_listCache = _container.ListCache;
_pageViewModelCache = _container.PageViewModelCache;
// User setup
_editorUser = new User();
_editorUser.Id = Guid.NewGuid();
_editorUser.Email = EditorEmail;
_editorUser.Username = EditorUsername;
_editorUser.IsAdmin = false;
_editorUser.IsEditor = true;
_adminUser = new User();
_adminUser.Id = Guid.NewGuid();
_adminUser.Email = AdminEmail;
_adminUser.Username = AdminUsername;
_adminUser.IsAdmin = true;
_adminUser.IsEditor = true;
_userService.Users.Add(_editorUser);
_userService.Users.Add(_adminUser);
SetUserContext(_adminUser);
}
示例7: Setup
public void Setup()
{
_settings = new ApplicationSettings();
_settings.AttachmentsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Attachments");
_attachmentPathUtil = new AttachmentPathUtil(_settings);
try
{
// Delete any existing attachments folder
// Remove the files 1st
if (Directory.Exists(_settings.AttachmentsFolder))
{
DirectoryInfo directoryInfo = new DirectoryInfo(_settings.AttachmentsFolder);
foreach (FileInfo file in directoryInfo.GetFiles())
{
File.Delete(file.FullName);
}
if (directoryInfo.Exists)
{
directoryInfo.Attributes = FileAttributes.Normal;
directoryInfo.Delete(true);
}
}
Directory.CreateDirectory(_settings.AttachmentsFolder);
}
catch (IOException e)
{
Assert.Fail("Unable to delete the attachments folder " + _settings.AttachmentsFolder + ", does it have a lock?" + e.ToString());
}
}
示例8: Setup
public void Setup()
{
_container = new MocksAndStubsContainer();
_applicationSettings = _container.ApplicationSettings;
_settingsService = _container.SettingsService;
_fileService = new LocalFileService(_applicationSettings, _settingsService);
try
{
// Delete any existing attachments folder
DirectoryInfo directoryInfo = new DirectoryInfo(_applicationSettings.AttachmentsFolder);
if (directoryInfo.Exists)
{
directoryInfo.Attributes = FileAttributes.Normal;
directoryInfo.Delete(true);
}
Directory.CreateDirectory(_applicationSettings.AttachmentsFolder);
}
catch (IOException e)
{
Assert.Fail("Unable to delete the attachments folder " + _applicationSettings.AttachmentsFolder + ", does it have a lock/explorer window open, or Mercurial open?" + e.ToString());
}
catch (ArgumentException e)
{
Assert.Fail("Unable to delete the attachments folder " + _applicationSettings.AttachmentsFolder + ", is EasyMercurial open?" + e.ToString());
}
}
示例9: UpgradeController
public UpgradeController(ApplicationSettings settings, IRepository repository, UserServiceBase userService,
IUserContext context, SettingsService settingsService, ConfigReaderWriter configReaderWriter)
: base(settings, userService, context, settingsService)
{
_repository = repository;
_configReaderWriter = configReaderWriter;
}
示例10: 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));
}
示例11: 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));
}
示例12: WikiExporter
public WikiExporter(ApplicationSettings applicationSettings, PageService pageService, ISettingsRepository settingsRepository, IPageRepository pageRepository, IUserRepository userRepository, IPluginFactory pluginFactory)
{
if (applicationSettings == null)
throw new ArgumentNullException(nameof(applicationSettings));
if (pageService == null)
throw new ArgumentNullException(nameof(pageService));
if (settingsRepository == null)
throw new ArgumentNullException(nameof(settingsRepository));
if (pageRepository == null)
throw new ArgumentNullException(nameof(pageRepository));
if (userRepository == null)
throw new ArgumentNullException(nameof(userRepository));
if (pluginFactory == null)
throw new ArgumentNullException(nameof(pluginFactory));
_applicationSettings = applicationSettings;
_pageService = pageService;
_sqlExportBuilder = new SqlExportBuilder(settingsRepository, userRepository, pageRepository, pluginFactory);
ExportFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "Export");
}
示例13: Setup
public void Setup()
{
_container = new MocksAndStubsContainer();
_applicationSettings = _container.ApplicationSettings;
_applicationSettings.LdapConnectionString = _ldapString;
_applicationSettings.LdapUsername = _username;
_applicationSettings.LdapPassword = _password;
_applicationSettings.AdminRoleName = _adminsGroupName;
_applicationSettings.EditorRoleName = _editorsGroupName;
_repository = _container.Repository;
List<IPrincipalDetails> adminUsers = new List<IPrincipalDetails>();
adminUsers.Add(new MockPrincipal() { SamAccountName = "admin1" });
adminUsers.Add(new MockPrincipal() { SamAccountName = "admin2" });
List<IPrincipalDetails> editorUsers = new List<IPrincipalDetails>();
editorUsers.Add(new MockPrincipal() { SamAccountName = "editor1" });
editorUsers.Add(new MockPrincipal() { SamAccountName = "editor2" });
_adProviderMock = new Mock<IActiveDirectoryProvider>();
_adProviderMock.Setup(x => x.GetMembers(_domainPath, _username, _password, _adminsGroupName)).Returns(adminUsers);
_adProviderMock.Setup(x => x.GetMembers(_domainPath, _username, _password, _editorsGroupName)).Returns(editorUsers);
_userService = new ActiveDirectoryUserService(_applicationSettings, _repository, _adProviderMock.Object);
}
示例14: 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));
}
示例15: MarkupConverter
/// <summary>
/// Creates a new markdown parser which handles the image and link parsing by the various different
/// markdown format parsers.
/// </summary>
/// <returns>An <see cref="IMarkupParser"/> for Creole,Markdown or Media wiki formats.</returns>
public MarkupConverter(ApplicationSettings settings, ISettingsRepository settingsRepository, IPageRepository pageRepository, IPluginFactory pluginFactory)
{
_externalLinkPrefixes = new List<string>()
{
"http://",
"https://",
"www.",
"mailto:",
"#",
"tag:"
};
_pluginFactory = pluginFactory;
_settingsRepository = settingsRepository;
_pageRepository = pageRepository;
_applicationSettings = settings;
// Create the UrlResolver for all wiki urls
HttpContextBase httpContext = null;
if (HttpContext.Current != null)
httpContext = new HttpContextWrapper(HttpContext.Current);
UrlResolver = new UrlResolver(httpContext);
if (!_applicationSettings.Installed)
{
// Skip the chain of creation, as the markup converter isn't needed but is created by
// StructureMap - this is required for installation
return;
}
CreateParserForMarkupType();
}