private void Method3(IServiceProvider serviceProvider, TestService1 service1)
            {
                if (service1 is null)
                {
                    throw new ArgumentNullException(nameof(service1));
                }

                if (service1.Called)
                {
                    throw new InvalidOperationException("Invalid method called!");
                }

                service1.Called  = true;
                service1.Success = false;

                serviceProvider.Call(this, nameof(Method3), allowPrivate: true);
            }
Example #2
0
 public static T Call <T>(this IServiceProvider services, object obj, string name, bool allowPrivate = false)
 {
     return((T?)services.Call(obj, name, returnType: typeof(T), allowPrivate: allowPrivate));
 }
Example #3
0
        public static object?Call(this IServiceProvider services, object obj, string name, Type?returnType = null, bool allowPrivate = false)
        {
            MethodInfo?cached = null;

            return(services.Call(ref cached, obj, name, returnType: returnType, allowPrivate: allowPrivate));
        }