Skip to content

Instantly share code, notes, and snippets.

View blyry's full-sized avatar

blyry

View GitHub Profile
@blyry
blyry / WhiteListPropertyResolver.cs
Created May 24, 2012 21:15
json.net whitelist converter
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
//Example Usage
/*
var otherTypeObj = new SomeOneElsesType();
var settings = new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
ContractResolver = new WhiteListPropertyResolver("Name","Number","Display","Required","MaxLen","MinLen","Type")
@blyry
blyry / HitchhikerTest.cs
Created March 6, 2012 20:34
Best unit test ever.
[Fact]
public void Should_be_able_to_wrap_interface_with_one_method()
{
Func<string, int> length = s => s.Length;
var wrapped = DelegateWrapper.WrapAs<IAnsweringEngine>( length );
Assert.NotNull( wrapped );
var i = wrapped.GetAnswer( "Answer to Life the Universe and Everything" );
Assert.Equal( 42, i );
}
//from http://kozmic.pl/2009/03/20/castle-dynamic-proxy-tutorial-part-viii-interface-proxy-without-target