Exemplo n.º 1
0
        public void Intercept(IInvocation invocation)
        {
            if (!typeof(T).IsAssignableFrom(invocation.TargetType))
            {
                throw new NotSupportedException($"This {nameof(PolicyProxy<T>)} is not support {invocation.TargetType.FullName}");
            }

            var name = invocation.GetMethodNameAndParameters();
            var p    = TryGetPolicy(name);

            if (p != null)
            {
                p.Execute(invocation.Proceed);
            }
            else
            {
                invocation.Proceed();
            }
        }