This library aims to manage references to fields or properties nested in other structures, similar in its idea to the ref keyword. Unlike with the ref keyword the wrapped property or field can be dynamically reassigned to a different base object, so the binding is not to a place in memory, but to a path pointing inside a data structure, which is itself similar to the concept of lenses.
usingRefer;usingstaticSystem.Console;publicclassBar{publicintX{get;set;}}publicclassFoo{publicBarB{get;}=newBar();}publicclassProgram{publicstaticvoidMain(){varfoo=newFoo(){B={X=5,},};varreference=foo.Bind(f =>f.B.X);WriteLine(reference);// 5floatvalue=reference;// Implicitly converts to its underlying type,// in this case int, which initializes the float valueWriteLine(value==5);// Truereference.Value=7;WriteLine(foo.B.X);// 7}}