本文整理汇总了C#中InMemoryViewFolder类的典型用法代码示例。如果您正苦于以下问题:C# InMemoryViewFolder类的具体用法?C# InMemoryViewFolder怎么用?C# InMemoryViewFolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InMemoryViewFolder类属于命名空间,在下文中一共展示了InMemoryViewFolder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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"));
}
开发者ID:rsmolnikov,项目名称:spark,代码行数:26,代码来源:ViewExplorerTests.cs
示例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));
}
开发者ID:Eilon,项目名称:spark,代码行数:26,代码来源:PdfViewResultTests.cs
示例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));
}
开发者ID:jamesfoster,项目名称:spark,代码行数:7,代码来源:ViewFolderBindingProviderTester.cs
示例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);
}
开发者ID:bbarry,项目名称:spark,代码行数:26,代码来源:UseMasterTester.cs
示例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>());
}
开发者ID:Eilon,项目名称:spark,代码行数:7,代码来源:InMemoryViewFolderTester.cs
示例6: Init
public void Init()
{
_folder = new InMemoryViewFolder
{
{string.Format("Home{0}Index.spark", Path.DirectorySeparatorChar), "alpha"}
};
_adapter = new LanguageKit.Folder(_folder);
}
开发者ID:Eilon,项目名称:spark,代码行数:8,代码来源:LanguageKitFolderTester.cs
示例7: Init
public void Init()
{
_folder = new InMemoryViewFolder
{
{"Home\\Index.spark", "alpha"}
};
_adapter = new LanguageKit.Folder(_folder);
}
开发者ID:subdigital,项目名称:spark,代码行数:8,代码来源:LanguageKitFolderTester.cs
示例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));
}
开发者ID:jamesfoster,项目名称:spark,代码行数:8,代码来源:ViewFolderBindingProviderTester.cs
示例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")));
}
开发者ID:Eilon,项目名称:spark,代码行数:10,代码来源:InMemoryViewFolderTester.cs
示例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"));
}
开发者ID:ronniebarker,项目名称:spark,代码行数:10,代码来源:CombinedViewFolderTester.cs
示例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"));
}
开发者ID:subdigital,项目名称:spark,代码行数:10,代码来源:InMemoryViewFolderTester.cs
示例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"));
}
开发者ID:adzerk,项目名称:spark,代码行数:11,代码来源:ViewFolderBindingProviderTester.cs
示例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;
}
开发者ID:joshuaflanagan,项目名称:docu,代码行数:12,代码来源:HtmlGenerator.cs
示例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());
}
开发者ID:ronniebarker,项目名称:spark,代码行数:12,代码来源:CombinedViewFolderTester.cs
示例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);
}
开发者ID:subdigital,项目名称:spark,代码行数:12,代码来源:InMemoryViewFolderTester.cs
示例16: OpenFromFirstViewFolder
public void OpenFromFirstViewFolder()
{
var first = new InMemoryViewFolder { { "one.txt", "one" } };
var second = new InMemoryViewFolder { { "one.txt", "two" } };
var viewFolder = new CombinedViewFolder(first, second);
using (var reader = new StreamReader(viewFolder.GetViewSource("one.txt").OpenViewStream()))
{
var content = reader.ReadToEnd();
Assert.AreEqual("one", content);
}
}
开发者ID:ronniebarker,项目名称:spark,代码行数:12,代码来源:CombinedViewFolderTester.cs
示例17: 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
}
开发者ID:Kragen2uk,项目名称:docu,代码行数:13,代码来源:HtmlGenerator.cs
示例18: ShouldRecogniseVariablesDeclaredInTheSameFile
public void ShouldRecogniseVariablesDeclaredInTheSameFile()
{
var filePath = "test\\TwoVars.spark";
var fileContent = "<var theNumberFive=\"5\" theNumberThree=\"3\" />";
var viewFolder = new InMemoryViewFolder { { filePath, fileContent } };
var viewExplorer = new ViewExplorer(viewFolder, filePath);
IList<string> vars = viewExplorer.GetLocalVariables();
Assert.That(vars.Count, Is.EqualTo(2));
Assert.That(vars[0], Is.EqualTo("theNumberFive"));
Assert.That(vars[1], Is.EqualTo("theNumberThree"));
}
开发者ID:rsmolnikov,项目名称:spark,代码行数:13,代码来源:ViewExplorerTests.cs
示例19: 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);
}
开发者ID:edgarbjorntvedt,项目名称:Forseti,代码行数:13,代码来源:PageGenerator.cs
示例20: TwoPartBindingsAreRecognized
public void TwoPartBindingsAreRecognized()
{
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.Count, Is.EqualTo(1));
Assert.That(bindings[0].ElementName, Is.EqualTo("foo"));
Assert.That(bindings[0].Phrases.Count(), Is.EqualTo(2));
Assert.That(bindings[0].Phrases.First().Nodes.Count, Is.EqualTo(1));
Assert.That(bindings[0].Phrases.Last().Nodes.Count, Is.EqualTo(1));
Assert.That(((BindingLiteral)bindings[0].Phrases.First().Nodes[0]).Text, Is.EqualTo("bar"));
Assert.That(((BindingLiteral)bindings[0].Phrases.Last().Nodes[0]).Text, Is.EqualTo("quux"));
Assert.That(bindings[0].Phrases.All(phrase => phrase.Type == BindingPhrase.PhraseType.Expression));
}
开发者ID:jamesfoster,项目名称:spark,代码行数:15,代码来源:ViewFolderBindingProviderTester.cs
注:本文中的InMemoryViewFolder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论