--
You received this message because you are subscribed to the Google Groups "Spark View Engine Dev" group.
To post to this group, send email to spar...@googlegroups.com.
To unsubscribe from this group, send email to spark-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spark-dev?hl=en.
Yea, I get the ISparkView not inheriting from IView part. I didn't think
about the other contexts Spark was usable when I wrote the e-mail, but
they are of course important and obvious when you think of them.
What I did discover, though, was that although what was returned from
ISparkViewEntry.CreateInstance() was ISparkView, the actual implementation
was Spark.Web.Mvc.SparkView which implements IView! So I can cast the
object returned from CreateInstance() to IView and treat it as such from
that point on, which creates the loose coupling I was aiming for.
I'm now also able to locate views in the CompiledViewHolder through the
following rather obscure (and too "Magic Strings" based for my taste)
SparkViewDescriptor:
string controller = context.RouteData.GetRequiredString("Controller");
string templateName = String.Format(@"{0}\{1}.spark", controller,
viewName);
string targetNamespace = String.Concat(GetType().Namespace,
".Controllers");
SparkViewDescriptor descriptor = new SparkViewDescriptor
{
Language = LanguageType.Default,
TargetNamespace = targetNamespace,
Templates = new[] { templateName, SharedSiteTemplate },
};
It would be so much better if we could just query based on
ControllerContext, ViewContext or something similar so Spark itself can do
this magic string concatenation based on its internal conventions which
imho shouldn't be known to the outside world. For instance, why do I need
to append '.Controllers' to the namespace?
Anyhoo, this works and I'm (fairly) happy. :)
-Asbjørn
>> spark-dev+...@googlegroups.com<spark-dev%2Bunsu...@googlegroups.com>