本文整理汇总了C#中InMemoryViewFolder.Add方法的典型用法代码示例。如果您正苦于以下问题:C# InMemoryViewFolder.Add方法的具体用法?C# InMemoryViewFolder.Add怎么用?C# InMemoryViewFolder.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InMemoryViewFolder
的用法示例。
在下文中一共展示了InMemoryViewFolder.Add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FileNotFoundException
public void FileNotFoundException()
{
var folder = new InMemoryViewFolder();
folder.Add(Path.Combine("Home", "Index.spark"), "stuff");
Assert.That(() => folder.GetViewSource(Path.Combine("Home", "List.spark")),
Throws.TypeOf<FileNotFoundException>());
}
示例2: HasViewCaseInsensitive
public void HasViewCaseInsensitive()
{
var folder = new InMemoryViewFolder();
Assert.IsFalse(folder.HasView("Home\\Index.spark"));
folder.Add("Home\\Index.spark", "stuff");
Assert.IsTrue(folder.HasView("Home\\Index.spark"));
Assert.IsFalse(folder.HasView("Home\\Index"));
Assert.IsTrue(folder.HasView("Home\\index.spark"));
Assert.IsTrue(folder.HasView("home\\INDEX.SPARK"));
}
示例3: HasViewCaseInsensitive
public void HasViewCaseInsensitive()
{
var folder = new InMemoryViewFolder();
Assert.IsFalse(folder.HasView(Path.Combine("Home", "Index.spark")));
folder.Add(Path.Combine("Home", "Index.spark"), "stuff");
Assert.IsTrue(folder.HasView(Path.Combine("Home", "Index.spark")));
Assert.IsFalse(folder.HasView(Path.Combine("Home", "Index")));
Assert.IsTrue(folder.HasView(Path.Combine("Home", "index.spark")));
Assert.IsTrue(folder.HasView(Path.Combine("home", "INDEX.SPARK")));
}
示例4: HtmlGenerator
public HtmlGenerator(IEnumerable<KeyValuePair<string, string>> templates)
: this()
{
var viewFolder = new InMemoryViewFolder();
foreach (var pair in templates)
{
viewFolder.Add(pair.Key, pair.Value);
}
engine.ViewFolder = viewFolder;
}
示例5: InMemoryViewFolderUsedByEngine
public void InMemoryViewFolderUsedByEngine()
{
var folder = new InMemoryViewFolder();
folder.Add("home\\index.spark", "<p>Hello world</p>");
var engine = new SparkViewEngine(new SparkSettings().SetPageBaseType(typeof (StubSparkView))){ViewFolder = folder};
var descriptor = new SparkViewDescriptor();
descriptor.Templates.Add("home\\index.spark");
var view = engine.CreateInstance(descriptor);
var contents = view.RenderView();
Assert.AreEqual("<p>Hello world</p>", contents);
}
示例6: HtmlGenerator
public HtmlGenerator(IEnumerable<KeyValuePair<string, string>> templates)
: this()
{
var viewFolder = new InMemoryViewFolder();
foreach (var pair in templates)
{
viewFolder.Add(pair.Key, pair.Value);
}
engine.ViewFolder = viewFolder;
CompiledViewHolder.Current = null; // reset the cached views
}
示例7: PageGenerator
public PageGenerator(IResourceManager resourceManager)
{
var template = resourceManager.GetStringFromAssemblyOf<PageGenerator>("Forseti.Pages.Spark.Harness.spark");
var settings = new SparkSettings().SetPageBaseType(typeof(HarnessView));
var templates = new InMemoryViewFolder();
_engine = new SparkViewEngine(settings)
{
ViewFolder = templates
};
templates.Add(TemplateName, template);
_descriptor = new SparkViewDescriptor().AddTemplate(TemplateName);
}
示例8: PageGenerator
public PageGenerator(IResourceManager resourceManager, IFramework framework)
{
var template = resourceManager.GetStringFromAssemblyOf<PageGenerator>("Forseti.Pages.Spark.Harness.spark");
_framework = framework;
var settings = new SparkSettings().SetPageBaseType(typeof(HarnessView));
var templates = new InMemoryViewFolder();
_engine = new SparkViewEngine(settings)
{
ViewFolder = templates
};
templates.Add(TemplateName, template); //"<for each=\"var s in Stuff\"><p>${s}</p></for>");
_descriptor = new SparkViewDescriptor().AddTemplate(TemplateName);
}
示例9: PageGenerator
public PageGenerator(IResourceManager resourceManager)
{
var template = resourceManager.GetStringFromAssemblyOf<PageGenerator>("Forseti.Pages.Spark.Harness.spark");
_jqueryJs = resourceManager.GetStringFromAssemblyOf<Forseti.Scripting.ScriptEngine>("Forseti.Scripting.Scripts.jquery.min.js");
_forsetiJs = resourceManager.GetStringFromAssemblyOf<Forseti.Scripting.ScriptEngine>("Forseti.Scripting.Scripts.forseti.js");
_requireJs = resourceManager.GetStringFromAssemblyOf<Forseti.Scripting.ScriptEngine>("Forseti.Scripting.Scripts.require.js");
_forsetiBootstrapperJs = resourceManager.GetStringFromAssemblyOf<Forseti.Scripting.ScriptEngine>("Forseti.Scripting.Scripts.forseti.bootstrapper.js");
var settings = new SparkSettings().SetPageBaseType(typeof(HarnessView));
var templates = new InMemoryViewFolder();
_engine = new SparkViewEngine(settings)
{
ViewFolder = templates
};
templates.Add(TemplateName, template);
_descriptor = new SparkViewDescriptor().AddTemplate(TemplateName);
}
示例10: LastModifiedChanges
public void LastModifiedChanges()
{
var folder = new InMemoryViewFolder();
folder.Add("Home\\Index.spark", "this is the file contents");
var source1 = folder.GetViewSource("Home\\Index.spark");
var lastModified1 = source1.LastModified;
folder.Set("Home\\Index.spark", "this is the file contents");
var source2 = folder.GetViewSource("Home\\Index.spark");
var lastModified2 = source2.LastModified;
Assert.AreNotEqual(lastModified1, lastModified2);
var lastModified1b = source1.LastModified;
var lastModified2b = source1.LastModified;
Assert.AreNotEqual(lastModified1, lastModified1b);
Assert.AreEqual(lastModified1b, lastModified2b);
}
示例11: UseAssemblyAndNamespaceFromSettings
public void UseAssemblyAndNamespaceFromSettings()
{
var settings = new SparkSettings()
.AddNamespace("System.Web")
.AddAssembly("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
.SetPageBaseType(typeof(StubSparkView));
var views = new InMemoryViewFolder();
views.Add("Home\\Index.spark", "<div>${ProcessStatus.Alive}</div>");
var engine = new SparkViewEngine(settings) {ViewFolder = views};
var descriptor = new SparkViewDescriptor();
descriptor.Templates.Add("home\\index.spark");
var contents = engine.CreateInstance(descriptor).RenderView();
Assert.AreEqual("<div>Alive</div>", contents);
}
示例12: FileNotFoundException
public void FileNotFoundException()
{
var folder = new InMemoryViewFolder();
folder.Add("Home\\Index.spark", "stuff");
folder.GetViewSource("Home\\List.spark");
}
示例13: UnicodeCharactersSurviveConversionToByteArrayAndBack
public void UnicodeCharactersSurviveConversionToByteArrayAndBack()
{
var folder = new InMemoryViewFolder();
folder.Add("Home\\fr.spark", "Fran\u00E7ais");
folder.Add("Home\\ru.spark", "\u0420\u0443\u0441\u0441\u043A\u0438\u0439");
folder.Add("Home\\ja.spark", "\u65E5\u672C\u8A9E");
Assert.That(ReadToEnd(folder, "Home\\fr.spark"), Is.EqualTo("Français"));
Assert.That(ReadToEnd(folder, "Home\\ru.spark"), Is.EqualTo("Русский"));
Assert.That(ReadToEnd(folder, "Home\\ja.spark"), Is.EqualTo("日本語"));
var settings = new SparkSettings().SetPageBaseType(typeof(StubSparkView));
var engine = new SparkViewEngine(settings) { ViewFolder = folder };
Assert.That(RenderView(engine, "Home\\fr.spark"), Is.EqualTo("Français"));
Assert.That(RenderView(engine, "Home\\ru.spark"), Is.EqualTo("Русский"));
Assert.That(RenderView(engine, "Home\\ja.spark"), Is.EqualTo("日本語"));
}
示例14: ReadFileContents
public void ReadFileContents()
{
var folder = new InMemoryViewFolder();
folder.Add("Home\\Index.spark", "this is the file contents");
var source = folder.GetViewSource("Home\\Index.spark");
using (var stream = source.OpenViewStream())
{
using(var reader = new StreamReader(stream))
{
var contents = reader.ReadToEnd();
Assert.AreEqual("this is the file contents", contents);
}
}
}