views:

70

answers:

1

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.

+1  A: 

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.

Tom Brothers
Excellent. Just what I needed.
Riri