(精华)2020年6月27日 C#类库 CastleAOPContext(Castle-AOP的封装)

using Castle.DynamicProxy;
using System;
using System.Reflection;

namespace Core.Util
{
    public class CastleAOPContext : IAOPContext
    {
        private readonly IInvocation _invocation;
        public CastleAOPContext(IInvocation invocation, IServiceProvider serviceProvider)
        {
            _invocation = invocation;
            ServiceProvider = serviceProvider;
        }
        public IServiceProvider ServiceProvider { get; }

        public object[] Arguments => _invocation.Arguments;

        public Type[] GenericArguments => _invocation.GenericArguments;

        public MethodInfo Method => _invocation.Method;

        public MethodInfo MethodInvocationTarget => _invocation.MethodInvocationTarget;

        public object Proxy => _invocation.Proxy;

        public object ReturnValue { get => _invocation.ReturnValue; set => _invocation.ReturnValue = value; }

        public Type TargetType => _invocation.TargetType;

        public object InvocationTarget => _invocation.InvocationTarget;
    }
}
©️2020 CSDN 皮肤主题: 猿与汪的秘密 设计师:上身试试 返回首页