Esempio n. 1
0
        public void CreateMethodDelegateByNameTest()
        {
            var testClass = new MockClass();

            LazyBinding.CreateMethodDelegate <Action>(testClass, "MockMethod")();
            Assert.AreEqual(1, testClass.TimesCalled);
        }
Esempio n. 2
0
        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");
        }