Spark SetPageBaseType 设置中应包含哪些内容

发布于 2024-08-23 09:47:51 字数 845 浏览 3 评论 0原文

我使用 Spark 直接从控制台应用程序输出一些 HTML。我的项目中有以下视图类。

//A shared view that all other views should use
public abstract class SharedView : AbstractSparkView
{
    public string BasePath = string.Empty;
}

public abstract class ApplicationView : SharedView
{
    public Application Application { get; set; }
} 

然后,我对 Spark 进行了以下设置,

var settings = new SparkSettings()
            .SetPageBaseType(typeof(ApplicationView )) //What should go in here!?
            .AddNamespace("SomeNameSpaces")
            ;

当我没有将 ApplicationView 作为 SetPageBaseType 时,我现在不断收到 CompilerException - 我不应该在那里拥有我的共享基础视图吗?

我尝试使用相同的引擎实例将多个不同的视图写入磁盘(具有不同的视图模型),然后我必须为每个具有不同的 SetPageBaseType 的引擎实例设置一个引擎实例(对于我正在渲染的当前视图) - 应该这样吗是这样吗?

基本上我需要上述方面的帮助以及 SetPageBaseType 的一般解释以及如何使用它。

I use Spark to output some HTML straight from a console app. I have the following view classes in my project.

//A shared view that all other views should use
public abstract class SharedView : AbstractSparkView
{
    public string BasePath = string.Empty;
}

public abstract class ApplicationView : SharedView
{
    public Application Application { get; set; }
} 

I then have the following setting for Spark

var settings = new SparkSettings()
            .SetPageBaseType(typeof(ApplicationView )) //What should go in here!?
            .AddNamespace("SomeNameSpaces")
            ;

I now keep getting a CompilerException when I not put the ApplicationView as the SetPageBaseType - shouldn't I have my shared base view there?

I try to use the same engine instance to write several different views to disk (with diffrent view models) and I then have to set up a engine instance for each one with diffrent SetPageBaseType (for the current view I'm rendering)- should that be so?

Bascially I need help with above and a general explanation of SetPageBaseType and how to use it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尸血腥色 2024-08-30 09:47:52

您可以通过直接更改引擎的设置属性的设置来更改每个视图的 PageBaseType。

engine.Settings.PageBaseType = typeof(ApplicationView).FullName;

我不久前为这个过程编写了一个简单的包装器......你可以找到它

You can change the PageBaseType per view by changing the setting directly off the engine's Setting property.

engine.Settings.PageBaseType = typeof(ApplicationView).FullName;

I wrote a simple wrapper for this process awhile back... you can find it here if you are interested.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文