public void CreatePropertyGetDelegateByNameTest() { var testClass = new MockClass() { MockProperty = "FooBar" }; string result = LazyBinding.CreatePropertyGetDelegate <string>(testClass, "MockProperty")(); Assert.AreEqual("FooBar", result); }
public void CreatePropertyGetDelegateTest() { var testClass = new MockClass() { MockProperty = "FooBar" }; PropertyInfo property = testClass.GetType().GetProperty("MockProperty"); string result = LazyBinding.CreatePropertyGetDelegate <string>(testClass, property)(); Assert.AreEqual("FooBar", result); }
private Log4NetLogger(object typeOrName) { // Create an ILog instance using reflection. Assembly log4net = LazyBinding.GetAssembly(log4netAssemblyName); object ILog = CreateILogInstance(log4net, typeOrName); // Get a set of function references. logInfo = LazyBinding.CreateMethodDelegate <Action <string> >(ILog, "Info", typeof(string)); logDebug = LazyBinding.CreateMethodDelegate <Action <string> >(ILog, "Debug", typeof(string)); logWarning = LazyBinding.CreateMethodDelegate <Action <string> >(ILog, "Warn", typeof(string)); logError = LazyBinding.CreateMethodDelegate <Action <string> >(ILog, "Error", typeof(string)); logErrorException = LazyBinding.CreateMethodDelegate <Action <string, Exception> >( ILog, "Error", typeof(string), typeof(Exception)); logIsDebugEnabled = LazyBinding.CreatePropertyGetDelegate <bool>(ILog, "IsDebugEnabled"); }