protected override MethodDefinition ImplementGuardMethod(GuardMethod metadata) { var source = metadata.Template; var newMethod = new MethodDefinition(source.Name, MethodAttributes.Public, module.TypeSystem.Boolean); source.CopyAttrsTo(newMethod); target.Methods.Add(newMethod); SetGuardMethodBody(newMethod, metadata.TraceTemplate.Level, metadata.TraceTemplate.Keywords); return(newMethod); }
protected virtual IEnumerable <GuardMethod> GetGuardMethods() { var loggersByName = Tracers.ToDictionary(m => m.Method.Name); foreach (var g in Type.Methods.Where(IsGuardMethod)) { if (loggersByName.TryGetValue(g.Name.Substring("Can".Length), out var lm)) { var guard = new GuardMethod { TraceTemplate = lm, Template = g, IsTemplate = !g.HasBody }; yield return(guard); } } }
protected abstract MethodDefinition ImplementGuardMethod(GuardMethod metadata);