Esempio n. 1
0
        public bool MethodCanBeInterceptedOnInstance(MethodInfo method, object?callTarget, [NotNullWhen(false)] out string?failReason)
        {
            if (callTarget is not null && DelegateCreationStrategy.IsResponsibleForCreating(callTarget.GetType()))
            {
                return(this.delegateCreationStrategy.MethodCanBeInterceptedOnInstance(method, callTarget, out failReason));
            }

            return(this.defaultCreationStrategy.MethodCanBeInterceptedOnInstance(method, callTarget, out failReason));
        }
Esempio n. 2
0
        public CreationResult CreateFake(Type typeOfFake, IProxyOptions proxyOptions, IDummyValueResolver resolver)
        {
            if (typeOfFake.GetTypeInfo().IsInterface)
            {
                return(this.defaultCreationStrategy.CreateFakeInterface(typeOfFake, proxyOptions));
            }

            return(DelegateCreationStrategy.IsResponsibleForCreating(typeOfFake)
                ? this.delegateCreationStrategy.CreateFake(typeOfFake, proxyOptions)
                : this.defaultCreationStrategy.CreateFake(typeOfFake, proxyOptions, resolver));
        }
Esempio n. 3
0
        public CreationResult CreateFakeWithoutLoopDetection(
            Type typeOfFake,
            IProxyOptions proxyOptions,
            IDummyValueResolver resolver,
            LoopDetectingResolutionContext resolutionContext)
        {
            if (typeOfFake.IsInterface)
            {
                return(this.defaultCreationStrategy.CreateFakeInterface(typeOfFake, proxyOptions));
            }

            return(DelegateCreationStrategy.IsResponsibleForCreating(typeOfFake)
                ? this.delegateCreationStrategy.CreateFake(typeOfFake, proxyOptions)
                : this.defaultCreationStrategy.CreateFake(typeOfFake, proxyOptions, resolver, resolutionContext));
        }
 public bool MethodCanBeInterceptedOnInstance(MethodInfo method, object callTarget, out string failReason) =>
 DelegateCreationStrategy.IsResponsibleForCreating(callTarget?.GetType())
         ? this.delegateCreationStrategy.MethodCanBeInterceptedOnInstance(method, callTarget, out failReason)
         : this.defaultCreationStrategy.MethodCanBeInterceptedOnInstance(method, callTarget, out failReason);