Well, According to Scott Gu we'd be able to download the binaries Next Week,
I can't wait to put my hands on that, and start finding the possibilities of this framework in conjunction with MonoRail.
Following users requests, I have just posted two documents to using.castleproject.org.
The first is an explanation about the CodeGenerator (from Contrib), and another one, on using the DictionaryAdapter.
Here are the links:
Related stuff:
Following many requests from users, I've created a screen cast in which I show how to setup a new MonoRail/AspView website, from scratch (no wizards).
CreatingMonoRailAspViewWebProjectFromScratchinVisualStudioExpress.wmv
On that demo, I've used Visual Web Developer 2008 Express and Visual C# 2008 Express, both in Beta2, just to show how you can simulate some of the "Web Application Project" experience in the Express editions. Of course it's much easier to work with a full Visual Studio with Web Application Project as you then have everything in a single application, and it's easier to handle.
Nothing on the demo is 2008 specific, and it runs on .NET 2.0, so VS2005 would do just fine here.
The demo is very simple, and I have generally just showed a "Hello World" level of setup. I hope to spare some time to follow up with setting up things like Windsor Integration, the Castle.Tools.CodeGenerator, and other cool stuff.
The links I use on the demo are:
I've used Windows Media Encoder to capture the screen, and my SHURE SM58 mic to record the narrating. It's a great mic, however plugged into my sorry excuse for a sound-card.
It's my first screen cast, and I'd love to hear comments from you people, both on the content and on the presentation.
I'm looking at the option of using Linq To SQL for persistence.
Basic assumptions:
Today I'm using NHibernate (so 1 and 3 are set), and AR Attributes (so 4 is set). As for querying, I resort to hql (nice, yet too stringy), ICriteria (still stringy) and NHQG (cool, super cool, yet coupled with NH, while Linq is a "query everything" language)
I tried Linq for SQL (on a VS C# 2008 Express Beta2). No designer. Hand coded the entity, and have used the attributes for mapping.
First problem encountered: in order to make a column lazy, I need to change the underlying type to Link<MyOriginalType>, and then I can tell the context (using a LoadingOptions) about whether to load the lazy properties.
Couldn't yet find a way to actually lazy load that property once the instance has already been loaded.
I much better like the way NH is handling things, with a runtime-generated proxy that takes care of lazy loading (among other stuff), so I get it without hassling my entities code.
Didn't even mention First and Second Level Caches.
I guess I'd have to try and hop into NHibernate.Linq, and try to help Ayende with bringing it forward. That would mean diving into NH code, something I haven't done for quite some time now ...
I've spent some times lately with Linq To SQL and have played a bit with the Mapping namespace.
Why I do not like it very much is a matter for a different post. The matter at hand is that I want the power of Linq, and I want the power of NHibernate, and I want the easy road of ActiveRecord.
What do I mean by that? I'd like:
the needed prequisites:
So, Ayende has kick-started it, and with some help from Bobby Diaz, we have a prototype level NHibernate provider for Linq.
To make it work with ActiveRecord, all you need is to add:
using System;
using Castle.ActiveRecord;
using Castle.ActiveRecord.Framework;
using NHibernate;
namespace NHibernate.Linq
{
public class ActiveRecordContext : NHibernateContext
{
public ActiveRecordContext() : base(null)
{
session = GetSession();
}
private ISession GetSession()
{
ISessionScope scope = SessionScope.Current;
if (scope == null)
throw new InvalidOperationException("You should be in a SessionScope()");
ISessionFactoryHolder holder = ActiveRecordMediator.GetSessionFactoryHolder();
return holder.CreateSession(typeof(ActiveRecordBase));
}
}
}
and now you can do stuff like:
using (new SessionScope())
{
ActiveRecordContext context = new ActiveRecordContext();
var q =
from c in context.Session.Linq<Category>()
select c;
foreach (Category c in q)
Console.WriteLine(c.Name);
}
Assuming Category has [ActiveRecord] mapping.
Problem:
Possible causes:
Setting XHTML output manually:
Thanks Mr. Joe Chang, from the Windows Live Writer team, who have pointed that out for me.
I'm writing this very post on Windows Live Writer.
In case you'd ask, I'm using the latest public version, which is not a Beta anymore (I think):
I've also just recommended WLW for a new blogger.
however, there are still some annoying things here, that I might've liked fixed.
How I wish it was an Open Source product ...
Scott Guthrie is going to present a demo application using the ASP.NET MVC Framework.
First episode is here: http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx
Very interesting. I can already see four things that my current VS2005/MonoRail/AspView/IIS5-6 stack lack.
Sounds bad?
Well:
So - all the downsides are taken care of.
Plus, the stack I use is being used in production environment by gazillion people (ok, AspView is not that common, but the ViewEngine is just 5% of the whole stack, and it's the rock solid part anyway). It is working with .NET 2.0 so I need not convince clients to go for installing .NET 3/3.5 on their shared hosting solution, and since it's open-source, I can tweak stuff for my needs without the need to wait for a hotfix/ServicePack that might never appear, if not too late.
And if I'm not enough of a jerk for ranting like that, I'm going to try (if I'd have enough time) to put up a sample application using MonoRail/AspView similar to Scott's, but this time, you would actually be able get the bits and run it on your machines.
Stay tuned.
I've been asked lately about the use of the ViewFilter mechanism in AspView.
I've once written about it briefly here on my blog, and you can see it at http://www.kenegozi.com/Blog/2007/01/08/introducing-viewfilters.aspx
However, I'll post another (a bit more realistic) example here.
Scenario: some kind of a CMS thing. You want to present the user with some markup, in both "preview" mode and "Source" modes.
If the server had direct access to the markup in a string literal, things were easy. That usually happens when the markup is to be supplied by an end user, either directly or through a WYSIWYG Html editor. You'd end up with something like:
public interface IContentItem
{
public string Markup { get; }
}
your view would look like:
... <h3>Preview:</h3>
<div><%=view.ContentItem.Markup %> </div>
<h3>Source:</h3>
<div><%=Helpers.Html.HtmlEncode(view.ContentItem.Markup) %> </div>
...
easy enough.
However, what if the piece of markup that you want to show, has some view-logic, so you have a template generating the markup from an entity? For example, this blog has a view "Posts/One" that gets a Post entity, and fits it into a single post markup, putting the title in a <h4>, tags in <span> with theit title and href, etc.
How can you show the markup source for that?
ViewFilter to the rescue.
In short - A ViewFilter is a way to transform a chunk of a view, using simple manipulations. Do not look for that on other View Engines, as it's currently an AspView-only feature.
Let's code our needed filter:
public class HtmlEncodeViewFilter : IViewFilter
{
public string ApplyOn(string input)
{
return HttpUtility.HtmlEncode(input);
}
}
and in the view:
...
<% foreach (Post post in view.Posts) { %>
<h3>Preview:</h3>
<subview:.Posts.One post="<%=post %>" > </subview:.Posts.One>
<h3>Source:</h3>
<filter:HtmlEncode>
<subview:.Posts.One post="<%=post %>" > </subview:.Posts.One>
</filter:HtmlEncode>
<% } %>
Hey - you won't even need to create that filter. AspView is supplied with four basic (however useful) filters:
Can you think of more reusable view filters? why not post them here, or better yet, supply a patch to AspView with you filters?
Following a request from Gauthier Segay, AspView now supports nested view components.
scenarion: you are using CaptureFor to inject markup from a view to a layout, and you want the injected markup to include a view component output.
in the layout:
...
<%=CapturedContent %>
...
in the view:
...
<component:CaptureFor id="CapturedContent">
Some markup
<component:SomeFancyStuff>Fancy component content</component:SomeFancyStuff>
</component:CaptureFor>
While working on that, I found out yet another problem. nested components of same type would brake
so:
<component:Bold><component:Bold>stuff</component:Bold></component:Bold>
would brake.
As you probably might know, the whole preprocessing of view, from AspView syntax to standard C# is done with Regular Expressions. For quickly doing the above, I helped myself to http://puzzleware.net/blogs/archive/2005/08/13/22.aspx in order to build the balanced tags aware regular expression, and now it works like a charm. Roy Osherove's Regulator was helpful, too.
So, as of revision 360 in Castle Contrib repository, nesting view components works (for both the trunk and the RC3 compatible branch)
As usual - go to http://www.aspview.com to get the binaries, or to http://svn.castleproject.org:8080/svn/castlecontrib/viewengines/aspview/ for the sources.
Cheers.
I wish I had the time (and cash) to go there, as great speakers would host there.
Anyway - if I would've got there, I'd go for:
Anecdotes:
If you set autoRecompilation="true" in your aspview section on web.config, then you need not use the vcompile.exe on every build. The views would get compiled in memory from sources.
Benefits: Change a view source, refresh the browser - viola, you can see he change impact. No need to rebuild the web project, the application is not restarted so no session is lost, and no need for "double refresh".
Still, when you deploy it's strongly advised that you'd run VCompile manually, copy the compiledViews.dll to the server, and set autoRecompilation="false" on the server's web.config.
The starter tutorial on using.castleproject.org is now updated, and you can download AspView binaries from http://www.aspview.com
Please use that (and other) new features and leave me some comments please ...
So you can tell me what you think on the new design, or any other thing (like what you think on the new changes to AspView, how you like working with the Castle stack, how great AspView is, how good looking I am, and any other kind of constructive criticism).
If you're reading my blog through a feed, please update your link to http://feeds.feedburner.com/kenegozi if you hadn't yet, the web server would appreciate it.