Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using FubuCore;
using FubuCore.Util;
using FubuMVC.Core.View.Model;
using FubuMVC.Razor.RazorModel;
using FubuMVC.Razor.Rendering;
using RazorEngine.Templating;
using RazorEngine.Text;
using ITemplate = RazorEngine.Templating.ITemplate;
@CoreyKaylor
CoreyKaylor / ModelUrlResolutionCache.cs
Created January 5, 2012 02:36
Transforms InputModel for FubuMVC into the route for asset files, this makes routes refactor friendly and safe from route changes
public class ModelUrlResolutionCache : IModelUrlResolver
{
static Cache<string, string> _inputModelTypeCache;
public ModelUrlResolutionCache(IUrlRegistry urlRegistry, BehaviorGraph graph)
{
if (_inputModelTypeCache == null)
_inputModelTypeCache = new Cache<string, string>(inputModel =>
{
var inputType = Type.GetType(inputModel)
<link href="~/Content/Site.css" type="text/css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.4.1.js" type="text/javascript" language="javascript" />
var order = db.GetCollection<Order>().Find(new { })
.Include(o => o.ProductsOrdered)
.First();
MongoConfiguration.Initialize(c => c.AddMap<PersonMap>());
using (var db = Mongo.Create("mongodb://localhost/test"))
{
var people = db.GetCollection<Person>();
people.Save(new Person { FirstName = "myfirst", LastName = "mylast" });
var person = (from p in people.AsQueryable()
where p.FirstName == "myfirst"
select p).Single();
Console.WriteLine(person.FirstName + " " + person.LastName);
}
public class DependencyWrapper : Wrapper
{
private readonly object dependency;
public DependencyWrapper(Type behaviorType, object dependency) : base(behaviorType)
{
this.dependency = dependency;
}
protected override FubuMVC.Core.Registration.ObjectGraph.ObjectDef buildObjectDef()