Skip to content

Instantly share code, notes, and snippets.

public class Person
{
public string Name{get;set;}
public Automobile Car {get;set;}
}
public class Automobile
{
public string Name {get;set;}
public string Colour {get;set;}
public HomeModule()
{
Get["/"] = parameters =>
{
return View["Index"];
};
this.After += AfterRequest(this.Context);
}
@jchannon
jchannon / Attribute.cs
Created April 10, 2012 13:27
Comparing 2 model properties
[AttributeUsage(AttributeTargets.Class)]
public class MatchAttribute : ValidationAttribute
{
public String SourceProperty { get; set; }
public String MatchProperty { get; set; }
public MatchAttribute(string source, string match)
{
SourceProperty = source;
MatchProperty = match;
public class MyAdaptor : IDataAnnotationsValidatorAdapter
{
protected readonly ValidationAttribute attribute;
public MyAdaptor(MatchAttribute attribute)
{
this.attribute = attribute;
}
public IEnumerable<ModelValidationRule> GetRules()
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Newtonsoft.Json;
namespace DinnerParty.Models
{
public class Dinner
{
public Person
{
public string Name {get;set;}
public string Address {get;set;}
public string TelNo {get;set;}
}
Get["/RSS"] = parameters =>
{
var peeps = GetPeople();
public class Dinner
{
/// <summary>
/// Id (in that exact case) is used by Raven.
/// If on a Url of /dinners/edit/162 Nancy will bind the Id property to 162 so,
/// we have to make sure that it starts with dinners/ so Raven can identify it properly
/// </summary>
private string id;
public string Id
{
@jchannon
jchannon / gist:3047138
Created July 4, 2012 12:42
TDD/IOC Help
public interface ISomething
{
void DoSomething();
}
public class SomethingA : ISomething
{
public void DoSomething()
{
namespace NinjectTest
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class Action : IGenre
{
public string GetTopTenMoviesInGenre()

#Hello!

##You ok?