当前位置: 首页>>代码示例>>C#>>正文


C# ITypeInfo.GetMethod方法代码示例

本文整理汇总了C#中ITypeInfo.GetMethod方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeInfo.GetMethod方法的具体用法?C# ITypeInfo.GetMethod怎么用?C# ITypeInfo.GetMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITypeInfo的用法示例。


在下文中一共展示了ITypeInfo.GetMethod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: loadStatics

        /// <summary>
        /// This should be a one time call to use reflection to find all the types and methods
        /// needed for the logging API.
        /// </summary>
        private static void loadStatics()
        {
            lock (InternalLog4netLogger.LOCK)
            {
                if (loadState != LoadState.Uninitialized)
                    return;

                loadState = LoadState.Loading;
                try
                {
                    loggerType = Type.GetType("Amazon.Runtime.Internal.Util.Logger");

                    // The LogManager and its methods
                    logMangerType = Type.GetType("log4net.Core.LoggerManager, log4net");
                    logMangerTypeInfo = TypeFactory.GetTypeInfo(logMangerType);
                    if (logMangerType == null)
                    {
                        loadState = LoadState.Failed;
                        return;
                    }

                    getLoggerWithTypeMethod = logMangerTypeInfo.GetMethod("GetLogger", new ITypeInfo[] { TypeFactory.GetTypeInfo(typeof(Assembly)), TypeFactory.GetTypeInfo(typeof(Type)) });

                    // The ILog and its methdods
                    logType = Type.GetType("log4net.Core.ILogger, log4net");
                    logTypeInfo = TypeFactory.GetTypeInfo(logType);

                    levelType = Type.GetType("log4net.Core.Level, log4net");
                    levelTypeInfo = TypeFactory.GetTypeInfo(levelType);

                    debugLevelPropertyValue = levelTypeInfo.GetField("Debug").GetValue(null);
                    infoLevelPropertyValue = levelTypeInfo.GetField("Info").GetValue(null);
                    errorLevelPropertyValue = levelTypeInfo.GetField("Error").GetValue(null);

                    systemStringFormatType = Type.GetType("log4net.Util.SystemStringFormat, log4net");

                    logMethod = logTypeInfo.GetMethod("Log", new ITypeInfo[] { TypeFactory.GetTypeInfo(typeof(Type)), levelTypeInfo, TypeFactory.GetTypeInfo(typeof(object)), TypeFactory.GetTypeInfo(typeof(Exception)) });
                    isEnabledForMethod = logTypeInfo.GetMethod("IsEnabledFor", new ITypeInfo[] { levelTypeInfo });

                    if (getLoggerWithTypeMethod == null ||
                        isEnabledForMethod == null ||
                        logType == null ||
                        levelType == null ||
                        logMethod == null)
                    {
                        loadState = LoadState.Failed;
                        return;
                    }

                    // If log4net logging is enabled, we attempt to activate log4net by calling XmlConfigurator.Configure()
                    if ((AWSConfigs.LoggingConfig.LogTo & LoggingOptions.Log4Net) == LoggingOptions.Log4Net)
                    {
                        ITypeInfo xmlConfiguratorType = TypeFactory.GetTypeInfo(Type.GetType("log4net.Config.XmlConfigurator, log4net"));
                        if (xmlConfiguratorType != null)
                        {
                            MethodInfo configureMethod = xmlConfiguratorType.GetMethod("Configure", new ITypeInfo[0]);
                            if (configureMethod != null)
                            {
                                configureMethod.Invoke(null, null);
                            }
                        }
                    }

                    loadState = LoadState.Success;
                }
                catch
                {
                    // Mark as failed so no attempted will be made on the logging methods.
                    loadState = LoadState.Failed;
                }
            }
        }
开发者ID:rossmas,项目名称:aws-sdk-net,代码行数:76,代码来源:Logger.Log4net.cs


注:本文中的ITypeInfo.GetMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。