コード例 #1
0
ファイル: LazyBindingTest.cs プロジェクト: artzub/LoggenCSG
        public void CreateMethodDelegateByNameTest()
        {
            var testClass = new MockClass();

            LazyBinding.CreateMethodDelegate <Action>(testClass, "MockMethod")();
            Assert.AreEqual(1, testClass.TimesCalled);
        }
コード例 #2
0
ファイル: Log4NetLogger.cs プロジェクト: artzub/LoggenCSG
        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");
        }