public void Initialize(ModuleDeclaration module) { this.loggingImplementation = new LoggingImplementationTypeBuilder(module); this.formatWriter = new StringFormatWriter(module); this.loggerType = module.FindType(typeof(Logger)); Predicate <MethodDefDeclaration> singleMessagePredicate = method => method.Parameters.Count == 1 && IntrinsicTypeSignature.Is(method.Parameters[0].ParameterType, IntrinsicType.String); this.categoryInitializerMethod = module.FindMethod(module.FindType(typeof(LogManager)), "GetLogger", singleMessagePredicate); this.writeDebugMethod = module.FindMethod(this.loggerType, "Trace", singleMessagePredicate); this.writeInfoMethod = module.FindMethod(this.loggerType, "Info", singleMessagePredicate); this.writeWarnMethod = module.FindMethod(this.loggerType, "Warn", singleMessagePredicate); this.writeErrorMethod = module.FindMethod(this.loggerType, "Error", singleMessagePredicate); this.writeFatalMethod = module.FindMethod(this.loggerType, "Fatal", singleMessagePredicate); this.getIsTraceEnabledMethod = module.FindMethod(this.loggerType, "get_IsTraceEnabled"); this.getIsInfoEnabledMethod = module.FindMethod(this.loggerType, "get_IsInfoEnabled"); this.getIsWarnEnabledMethod = module.FindMethod(this.loggerType, "get_IsWarnEnabled"); this.getIsErrorEnabledMethod = module.FindMethod(this.loggerType, "get_IsErrorEnabled"); this.getIsFatalEnabledMethod = module.FindMethod(this.loggerType, "get_IsFatalEnabled"); }
public void Initialize(ModuleDeclaration module) { this.loggingImplementation = new LoggingImplementationTypeBuilder(module); this.formatWriter = new StringFormatWriter(module); this.loggerType = module.FindType(typeof(Logger)); Predicate<MethodDefDeclaration> singleMessagePredicate = method => method.Parameters.Count == 1 && IntrinsicTypeSignature.Is(method.Parameters[0].ParameterType, IntrinsicType.String); this.categoryInitializerMethod = module.FindMethod(module.FindType(typeof(LogManager)), "GetLogger", singleMessagePredicate); this.writeDebugMethod = module.FindMethod(this.loggerType, "Trace", singleMessagePredicate); this.writeInfoMethod = module.FindMethod(this.loggerType, "Info", singleMessagePredicate); this.writeWarnMethod = module.FindMethod(this.loggerType, "Warn", singleMessagePredicate); this.writeErrorMethod = module.FindMethod(this.loggerType, "Error", singleMessagePredicate); this.writeFatalMethod = module.FindMethod(this.loggerType, "Fatal", singleMessagePredicate); this.getIsTraceEnabledMethod = module.FindMethod(this.loggerType, "get_IsTraceEnabled"); this.getIsInfoEnabledMethod = module.FindMethod(this.loggerType, "get_IsInfoEnabled"); this.getIsWarnEnabledMethod = module.FindMethod(this.loggerType, "get_IsWarnEnabled"); this.getIsErrorEnabledMethod = module.FindMethod(this.loggerType, "get_IsErrorEnabled"); this.getIsFatalEnabledMethod = module.FindMethod(this.loggerType, "get_IsFatalEnabled"); }
public void Initialize(ModuleDeclaration module) { this.module = module; this.formatWriter = new StringFormatWriter(module); ITypeSignature traceTypeSignature = module.Cache.GetType(typeof(System.Diagnostics.Trace)); this.writeLineString = module.FindMethod(traceTypeSignature, "WriteLine", method => method.Parameters.Count == 1 && IntrinsicTypeSignature.Is(method.Parameters[0].ParameterType, IntrinsicType.String)); this.traceInfoString = module.FindMethod(traceTypeSignature, "TraceInformation", method => method.Parameters.Count == 1 && IntrinsicTypeSignature.Is(method.Parameters[0].ParameterType, IntrinsicType.String)); this.traceInfoFormat = module.FindMethod(traceTypeSignature, "TraceInformation", method => method.Parameters.Count == 2 && IntrinsicTypeSignature.Is(method.Parameters[0].ParameterType, IntrinsicType.String) && method.Parameters[1].ParameterType.BelongsToClassification(TypeClassifications.Array)); this.traceWarningString = module.FindMethod(traceTypeSignature, "TraceWarning", method => method.Parameters.Count == 1 && IntrinsicTypeSignature.Is(method.Parameters[0].ParameterType, IntrinsicType.String)); this.traceWarningFormat = module.FindMethod(traceTypeSignature, "TraceWarning", method => method.Parameters.Count == 2 && IntrinsicTypeSignature.Is(method.Parameters[0].ParameterType, IntrinsicType.String) && method.Parameters[1].ParameterType.BelongsToClassification(TypeClassifications.Array)); this.traceErrorString = module.FindMethod(traceTypeSignature, "TraceError", method => method.Parameters.Count == 1 && IntrinsicTypeSignature.Is(method.Parameters[0].ParameterType, IntrinsicType.String)); this.traceErrorFormat = module.FindMethod(traceTypeSignature, "TraceError", method => method.Parameters.Count == 2 && IntrinsicTypeSignature.Is(method.Parameters[0].ParameterType, IntrinsicType.String) && method.Parameters[1].ParameterType.BelongsToClassification(TypeClassifications.Array)); }