Пример #1
0
        private APIFactory()
        {
            methodProxy = new MethodProxy(this);
            providers   = new Dictionary <Type, Func <object> >();

            RegisterSingleton(() => methodProxy);
        }
Пример #2
0
            public RequireValueClass(IMethodProxy methodProxy, int x)
            {
                if (methodProxy is null)
                {
                    throw new ArgumentNullException(nameof(methodProxy));
                }

                X = x;
            }
Пример #3
0
        public void Intercept(IInvocation invocation)
        {
            var          attrs           = invocation.Method.CustomAttributes.Select(p => p.AttributeType).ToList();
            IMethodProxy lastMethodProxy = null;


            foreach (var attr in attrs)
            {
                if (attr == typeof(SafeExecuteAttribute))
                {
                    lastMethodProxy = new SafeExecuteAttribute(lastMethodProxy, invocation);
                }
                else if (attr == typeof(PerformanceLogAttribute))
                {
                    lastMethodProxy = new PerformanceLogAttribute(lastMethodProxy, invocation);
                }
            }
            lastMethodProxy.Execute();
        }
Пример #4
0
 public SafeExecuteAttribute(IMethodProxy nextProxy, IInvocation innerInvocation) : base(nextProxy, innerInvocation)
 {
 }
Пример #5
0
 public PerformanceLogAttribute(IMethodProxy nextProxy, IInvocation innerInvocation) : base(nextProxy, innerInvocation)
 {
 }
Пример #6
0
 public BaseMethodProxy(IMethodProxy nextProxy, IInvocation innerInvocation)
 {
     InnerInvocation = innerInvocation;
     NextProxy       = nextProxy;
 }