예제 #1
0
        public static T InterceptWithPolicy <T>(this IProxyGenerator generator,
                                                T instance,
                                                IReadOnlyPolicyRegistry policyReadOnlyRegistry)
            where T : class
        {
            if (instance == null)
            {
                throw new ArgumentNullException(nameof(instance));
            }
            if (policyReadOnlyRegistry == null)
            {
                throw new ArgumentNullException(nameof(policyReadOnlyRegistry));
            }

            var interceptor = new PolicyInterceptor(policyReadOnlyRegistry);

            return(generator.Intercept(instance, interceptor));
        }
예제 #2
0
        public static object InterceptWithPolicy(this IProxyGenerator generator,
                                                 Type type,
                                                 object instance,
                                                 IReadOnlyPolicyRegistry policyReadOnlyRegistry)
        {
            if (instance == null)
            {
                throw new ArgumentNullException(nameof(instance));
            }
            if (policyReadOnlyRegistry == null)
            {
                throw new ArgumentNullException(nameof(policyReadOnlyRegistry));
            }

            var interceptor = new PolicyInterceptor(policyReadOnlyRegistry);

            return(generator.Intercept(type, instance, interceptor));
        }