Beispiel #1
0
        /// <summary>
        /// Build the interceptor.
        /// </summary>
        /// <returns></returns>
        public T Build()
        {
            if (null == _instance)
            {
                throw new InvalidOperationException($"You must call the {nameof(For)} method and pass in a concrete instance of the interface implementation. ");
            }

            return(InterceptorProxy <T> .Create(_instance, BeforeExecutionRules, StubExecutionRules, AfterExecutionRules, _taskWaiter));
        }
 /// <summary>
 /// Creates an instance of <typeparamref name="TInstance"/> that will be intercepted with the specified interceptor.
 /// </summary>
 /// <typeparam name="TInstance">The type of the instance.</typeparam>
 /// <param name="interceptor">An interceptor instance to apply.</param>
 /// <param name="instance">The real instance of the type.</param>
 /// <returns><typeparamref name="TInstance"/> proxy instance.</returns>
 /// <exception cref="ArgumentNullException">The <paramref name="instance"/> is null.</exception>
 /// <exception cref="ArgumentNullException">The <paramref name="interceptor"/> is null.</exception>
 public static TInstance CreateProxy <TInstance>(IInterceptor interceptor, TInstance instance)
     where TInstance : class
 => InterceptorProxy <TInstance> .Create(instance, interceptor);