Created: 2012-03-22 00:29
Updated: 2018-01-13 11:45



NJection provides a way to inject .NET code at runtime using configuration files.
Through parsing a configuration file an expression tree is built and can be later on compiled and run, thus, giving
thepossibility to inject different pieces of code.

Please visit the github pages to see the documentation.


Parsing the configuration file is done by using the ExpressionBuilder's Traverse method:

var expression = ExpressionBuilder.Traverse<Action<string>>(@"C:\Example.config");
var actionOfString = expression.Compile();

actionOfString("Hello World!");


Here we defined a method call to WriteLine of the static class Console.

<?xml version="1.0" encoding="utf-8"?>
  <expression type="Lambda" typeof="System.Action`1[System.String]">
   <expression type="Call" typeof="System.Console" kind="Static" methodName="WriteLine">
     <expression ref="valueParameter"/>
    <expression type="Parameter" typeof="System.String" name="valueParameter"/>
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more