Пример #1
0
 protected virtual void WeaveMethod(MethodDefinition method, Injection injection)
 {
     if (injection.Effect is AfterAdviceEffect)
     {
         var process = new AdviceAfterProcess(_log, method, injection.Source, (AfterAdviceEffect)injection.Effect);
         process.Execute();
     }
     else if (injection.Effect is BeforeAdviceEffect)
     {
         var process = new AdviceBeforeProcess(_log, method, injection.Source, (BeforeAdviceEffect)injection.Effect);
         process.Execute();
     }
     else
     {
         throw new System.Exception("Unknown advice type.");
     }
 }
Пример #2
0
        protected virtual void WeaveMethod(MethodDefinition method, InjectionDefinition injection)
        {
            switch (injection.Effect)
            {
            case AfterAdviceEffect _:
            {
                var process = new AdviceAfterProcess(_log, method, injection);
                process.Execute();
                break;
            }

            case BeforeAdviceEffect _:
            {
                var process = new AdviceBeforeProcess(_log, method, injection);
                process.Execute();
                break;
            }

            case null: throw new ArgumentNullException(nameof(injection), "Effect is null.");

            default: throw new NotSupportedException($"Unknown effect type. {injection.Effect.GetType().Name}");
            }
        }