CNeptune improve productivity & efficiency by urbanize .net module with meta-code to lay foundation for frameworks
CNeptune is an util based on mono.cecil to rewrite .net assembly to inject all the needs to control execution flow in order to help architects to build a productive and efficient architecture.
neptune.exe "C:\...\Assembly.dll"
neptune.exe "C:\...\Project.csproj" "Debug"
PM> Install-Package CNeptune
Business
public class Calculator
{
public int Add(int a, int b)
{
return a + b;
}
}
Obtain the delegate to manage a method of 'Calculator'
var _update = typeof(Calculator).GetNestedType("<Neptune>", BindingFlags.NonPublic).GetField("<Update>").GetValue(null) as Action<MethodBase, Func<MethodInfo, MethodInfo>>;
Define 'Add' method to inject a console 'Hello World' before call.
_update
(
typeof(Calculator).GetMethod("Add"),
_Method =>
{
var _method = new DynamicMethod(string.Empty, typeof(int), new Type[] { typeof(Calculator), typeof(int), typeof(int) }, typeof(Calculator), true);
var _body = _method.GetILGenerator();
_body.EmitWriteLine("Hello World");
_body.Emit(OpCodes.Ldarg_0); //this
_body.Emit(OpCodes.Ldarg_1); //a
_body.Emit(OpCodes.Ldarg_2); //b
_body.Emit(OpCodes.Call, _Method);
_body.Emit(OpCodes.Ret);
return _method;
}
);