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