本文整理汇总了C#中InMemoryViewFolder类的典型用法代码示例。如果您正苦于以下问题:C# InMemoryViewFolder类的具体用法?C# InMemoryViewFolder怎么用?C# InMemoryViewFolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InMemoryViewFolder类属于命名空间,在下文中一共展示了InMemoryViewFolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldReturnNameOfPartialsFound
public void ShouldReturnNameOfPartialsFound()
{
var viewFolder = new InMemoryViewFolder
{
{"Shared\\Application.spark","<html><body><use content=\"main\" /></body></html>"},
{"Shared\\_PartialMustBeFound.spark","This partial should always be found"},
{"Home\\index.spark","Home Page"},
{"Home\\_HomePartial.spark","This Partial should only be found from Home"},
{"Other\\index.spark","Home Page"},
{"Other\\_OtherPartial.spark","This Partial should only be found from Other"},
};
var homeExplorer = new ViewExplorer(viewFolder, "Home\\index.spark");
var homePartials = homeExplorer.GetRelatedPartials();
var otherExplorer = new ViewExplorer(viewFolder, "Other\\index.spark");
var otherPartials = otherExplorer.GetRelatedPartials();
Assert.That(homePartials.Count, Is.EqualTo(2));
Assert.That(homePartials[0], Is.EqualTo("HomePartial"));
Assert.That(homePartials[1], Is.EqualTo("PartialMustBeFound"));
Assert.That(otherPartials.Count, Is.EqualTo(2));
Assert.That(otherPartials[0], Is.EqualTo("OtherPartial"));
Assert.That(otherPartials[1], Is.EqualTo("PartialMustBeFound"));
}
示例2: PdfResultShouldWriteToOutputStream
public void PdfResultShouldWriteToOutputStream()
{
var settings = new SparkSettings();
var viewFolder = new InMemoryViewFolder
{
{
"foo/bar.spark",
HelloWorldXml
}
};
var factory = new SparkViewFactory(settings)
{
ViewFolder = viewFolder
};
var stream = new MemoryStream();
var controllerContext = GetControllerContext(stream);
var result = new PdfViewResult
{
ViewEngineCollection = new ViewEngineCollection(new[] { factory })
};
result.ExecuteResult(controllerContext);
Assert.That(stream.Length, Is.Not.EqualTo(0));
}
示例3: HashCanBeUsedToDeclareStatementsInsteadOfOutputExpressions
public void HashCanBeUsedToDeclareStatementsInsteadOfOutputExpressions()
{
var viewFolder = new InMemoryViewFolder { { "bindings.xml", "<bindings><element name='foo'><start>#bar;</start><end>#quux;</end></element></bindings>" } };
var provider = new DefaultBindingProvider();
var bindings = provider.GetBindings(viewFolder).ToList();
Assert.That(bindings[0].Phrases.All(phrase => phrase.Type == BindingPhrase.PhraseType.Statement));
}
示例4: EmptyMasterPreventsDefaultLayout
public void EmptyMasterPreventsDefaultLayout()
{
var settings = new SparkSettings()
.SetPageBaseType(typeof(StubSparkView));
var container = new SparkServiceContainer(settings);
var viewFolder = new InMemoryViewFolder
{
{"Home\\Index.spark", "<use master=\"\"/><p>Hello world</p><content:title>bar</content:title>"},
{"Layouts\\Application.spark", "<h1>alpha</h1><use:view/><p>beta</p>"}
};
container.SetServiceBuilder<IViewFolder>(c => viewFolder);
var engine = container.GetService<ISparkViewEngine>();
var descriptor = new SparkViewDescriptor()
.AddTemplate("Home\\Index.spark")
.AddTemplate("Layouts\\Application.spark");
var view = engine.CreateInstance(descriptor);
var contents = view.RenderView();
engine.ReleaseInstance(view);
Assert.AreEqual("<p>Hello world</p>", contents);
}
示例5: 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>());
}
示例6: Init
public void Init()
{
_folder = new InMemoryViewFolder
{
{string.Format("Home{0}Index.spark", Path.DirectorySeparatorChar), "alpha"}
};
_adapter = new LanguageKit.Folder(_folder);
}
示例7: Init
public void Init()
{
_folder = new InMemoryViewFolder
{
{"Home\\Index.spark", "alpha"}
};
_adapter = new LanguageKit.Folder(_folder);
}
示例8: MissingFileDoesNotCauseException
public void MissingFileDoesNotCauseException()
{
var viewFolder = new InMemoryViewFolder();
var provider = new DefaultBindingProvider();
var bindings = provider.GetBindings(viewFolder).ToList();
Assert.That(bindings.Count, Is.EqualTo(0));
}
示例9: 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")));
}
示例10: HasTemplate
public void HasTemplate()
{
var first = new InMemoryViewFolder { { "one.txt", "one" } };
var second = new InMemoryViewFolder { { "two.txt", "two" } };
var viewFolder = new CombinedViewFolder(first, second);
Assert.IsTrue(viewFolder.HasView("one.txt"));
Assert.IsTrue(viewFolder.HasView("two.txt"));
Assert.IsFalse(viewFolder.HasView("three.txt"));
}
示例11: 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"));
}
示例12: BindingTableCanLoadFromViewFolder
public void BindingTableCanLoadFromViewFolder()
{
var viewFolder = new InMemoryViewFolder { { "bindings.xml", "<bindings><element name='foo'>bar</element></bindings>" } };
var provider = new DefaultBindingProvider();
var bindings = provider.GetBindings(viewFolder).ToList();
Assert.That(bindings.Count, Is.EqualTo(1));
Assert.That(bindings[0].ElementName, Is.EqualTo("foo"));
Assert.That(bindings[0].Nodes.Count, Is.EqualTo(1));
Assert.That(((BindingLiteral)bindings[0].Nodes[0]).Text, Is.EqualTo("bar"));
}
示例13: 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;
}
示例14: ListFilesWithDedupe
public void ListFilesWithDedupe()
{
var first = new InMemoryViewFolder { { "home\\three.txt", "three" }, { "home\\one.txt", "one" } };
var second = new InMemoryViewFolder { { "home\\two.txt", "two" }, { "home\\three.txt", "three" } };
var viewFolder = new CombinedViewFolder(first, second);
var views = viewFolder.ListViews("home");
Assert.AreEqual(3, views.Count);
Assert.Contains("home\\one.txt", views.ToArray());
Assert.Contains("home\\two.txt", views.ToArray());
Assert.Contains("home\\three.txt", views.ToArray());
}
示例15: 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);
}