예제 #1
0
            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);
            }
예제 #2
0
        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);
                }
            }
        }
예제 #3
0
 protected abstract MethodDefinition ImplementGuardMethod(GuardMethod metadata);