Generic base type to pageBaseType

129 views
Skip to first unread message

Rei

unread,
Jul 1, 2009, 6:13:38 AM7/1/09
to Spark View Engine Dev
Hi everyone, I was wondering if anyone knows how to configure spark to
use a type which has a generic parameter as in

public class IRGenericViewPage<T> { }

I've tried

web.config

pageBaseType="IRGenericViewPage", pageBaseType="IRGenericViewPage
[[TModel]]", pageBaseType="IRGenericViewPage[[T]]"

or using a SparkSetting object and I always get the same

Spark.Compiler.CompilerException: Dynamic view compilation failed
error CS0305: Using the generic type 'IRGenericViewPage<TModel>'
requires '1' type arguments

more output:

public class Viewe69396d7e5b0449ca9300bf8c0cec97d : IRGenericViewPage

or

public class Viewe69396d7e5b0449ca9300bf8c0cec97d : IRGenericViewPage
[[TModel]]

If anyone knows how to fix this i'd greatly appreciate it.


Rei

unread,
Jul 1, 2009, 6:18:01 AM7/1/09
to Spark View Engine Dev
Dynamic view compilation failed.
PathToTemp\pf90w8_d.0.cs(17,71): error CS1514: { expected
PathToTemp\pf90w8_d.0.cs(17,72): error CS1001: Identifier expected
PathToTemp\pf90w8_d.0.cs(17,80): error CS1031: Type expected
PathToTemp\pf90w8_d.0.cs(17,80): error CS1519: Invalid token ']' in
class, struct, or interface member declaration

1 Imports here
6
7 namespace OMG.Controllers
8 {
9
10 [global::Spark.SparkViewAttribute(
11 TargetNamespace="OMG.Controllers",
12 Templates = new string[] {
13 "home\\index.spark",
14 "Layouts\\Application.spark",
15 "Layouts\\Html.spark"
16 })]
17 public class Viewe62bbb1780a948c69e3f42d0c986acfd :
IRGenericViewPage[[TModel]]
18 {

Rei

unread,
Jul 1, 2009, 7:01:47 AM7/1/09
to Spark View Engine Dev
Ok, I think I found a work around. Declare both a generic and non
generic base type as in

IRGeneric : SparkView
and
IRGeneric<T> : SparkView<T>

The correct type will be used while generating the page. Hope this
helps someone.

Morten Maxild

unread,
Jul 1, 2009, 7:04:36 AM7/1/09
to spar...@googlegroups.com
2 methods:

1)

In config (or code) you have to leave out the generic argument, and then declare the model type (to __close__ the generic type) in the spark template like this

<viewdata model="SomeViewModel"/>

Note: When setting up the default pagebasetype in code, you need to have both a generic and a non-generic type of your basetype (from external app config this is not an issue, I guess). I find this a bit strange, but this is why Spark has both SparkView and SparkView<TModel> types in its MVC assembly.

2)

Or you can declare the closed pagebasetype in the spark template as

<use pageBaseType="IRGenericViewPage[[SomeViewModel]]"/>

If your basetype varies, and/or you have > 1 generic arguments on your basetype.

Hope this helps
Maxild

Morten Maxild

unread,
Jul 1, 2009, 7:06:48 AM7/1/09
to spar...@googlegroups.com
Didn't see your workaround...but you still need to control the generic argument using one of the 2 methods mentioned earlier

>-----Original Message-----
>From: spar...@googlegroups.com [mailto:spar...@googlegroups.com] On
>Behalf Of Rei
>Sent: Wednesday, July 01, 2009 1:02 PM
>To: Spark View Engine Dev

Rei

unread,
Jul 1, 2009, 7:22:14 AM7/1/09
to Spark View Engine Dev
Yes exactly what I found, thank you very much.
Reply all
Reply to author
Forward
0 new messages