This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GitHubModelBinder : IModelBinder | |
{ | |
public object Bind(NancyContext context, Type modelType, params string[] blackList) | |
{ | |
if(modelType == typeof(GitHubPostReceiveHookData)) | |
{ | |
string jsonDataChunk = string.Empty; | |
using (var jsonReader = new StreamReader(context.Request.Body)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "after" : "87f611142a2067dec246b0be1043aad9959d9ee0", | |
"base_ref" : "refs/heads/test", | |
"before" : "ba12bb5b6a2f9fa19191bb07b919e4c16d149dc8", | |
"commits" : [ { "added" : [ ], | |
"author" : { "email" : "shift.key@gmail.com", | |
"name" : "Brendan Forster", | |
"username" : "shiftkey" | |
}, | |
"distinct" : false, | |
"id" : "4ba4270541ec579bf02e2db5de2f08cff638f040", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Offset OpCode | |
0 ldnull | |
1 ldarg.0 | |
2 ldc.i4.2 | |
3 newarr System.Object | |
8 stloc.0 | |
9 ldloc.0 | |
10 ldc.i4.0 | |
11 ldarg.1 | |
12 stelem.ref |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Offset OpCode | |
0 ldnull | |
1 ldarg.0 | |
2 ldc.i4.2 | |
3 newarr System.Object | |
8 stloc.0 | |
9 ldloc.0 | |
10 ldc.i4.0 | |
11 ldarg.1 | |
12 stelem.ref |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string Format(string format, object arg0, object arg1) | |
{ | |
return Format(null, format, new object[] { arg0, arg1 }); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EmitHelper emit = new AssemblyBuilderHelper("HelloWorld.dll") | |
.DefineType ("Hello", typeof(object), typeof(IHello)) | |
.DefineMethod(typeof(IHello).GetMethod("SayHello")) | |
.Emitter; | |
emit | |
// string.Format("Hello, {0}!", toWhom) | |
// | |
.ldstr ("Hello, {0}!") | |
.ldarg_1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
A a = new A(); | |
ITest aAsITest = a.Duck<ITest>(); | |
} | |
} | |
public class A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static ClassFactory() | |
{ | |
_assemblyBuilder = new AssemblyBuilderHelper(GetGeneratedAssemblyPath()); | |
} | |
private static string GetGeneratedAssemblyPath() | |
{ | |
return @".\Duck.Tape.Generated.dll"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var typeBuilder = _assemblyBuilder.DefineType(GetGeneratedTypeName(), typeof(object), InterfaceToImplement); | |
//create private field | |
var classToWrapField = typeBuilder.DefineField(GetGeneratedToWrapFieldName(), ClassToWrap, FieldAttributes.Private); | |
//map interface members | |
MapInterfaceProperties(classToWrapField, typeBuilder); | |
MapInterfaceEvents(classToWrapField, typeBuilder); | |
MapInterfaceMethods(classToWrapField, typeBuilder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void DefineConstructor(FieldInfo classToWrapField, TypeBuilderHelper typeBuilder) | |
{ | |
typeBuilder | |
//take an instance of 'ClassToWrap' as constructor parameter | |
.DefinePublicConstructor(ClassToWrap) | |
.Emitter | |
//: base() | |
.ldarg_0 | |
.call(typeof(object).GetConstructors()[0]) | |
//this.[fieldName] = [constructorParameter] |
OlderNewer