Amazon.Runtime.Internal.Util.InternalLog4netLogger.loadStatics C# (CSharp) Метод

loadStatics() приватный статический Метод

This should be a one time call to use reflection to find all the types and methods needed for the logging API.
private static loadStatics ( ) : void
Результат void
        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.Logging & 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;
                }
            }
        }