Esempio n. 1
0
 public static bool TryInject(
     this IServiceProvider serviceProvider,
     object target,
     Type attributeType,
     ITrace logger = null,
     Func <Type, object> instanceProvider = null,
     bool tryConstructArguments           = false,
     bool?requireConstructorAttributes    = null,
     params Type[] constructorAttributeTypes)
 => ServiceConstructorMethods.TryInject(
     serviceProvider as IServiceRegistrationProvider
     ?? new ServiceRegistrationProviderWrapper(serviceProvider),
     target,
     attributeType,
     logger,
     instanceProvider,
     tryConstructArguments,
     requireConstructorAttributes,
     constructorAttributeTypes);
Esempio n. 2
0
        public static bool TryConstruct(
            this IServiceProvider serviceProvider,
            Type targetType,
            out object service,
            ITrace logger = null,
            Func <Type, object> instanceProvider = null,
            bool tryConstructArguments           = false,
            bool?requireAttributes = null,
            params Type[] attributeTypes)
        {
            IServiceRegistrationProvider serviceRegistrationProvider
                = serviceProvider as IServiceRegistrationProvider
                  ?? new ServiceRegistrationProviderWrapper(serviceProvider);

            return(ServiceConstructorMethods.TryConstruct(
                       targetType,
                       out service,
                       new ServiceConstructorRequest(logger),
                       serviceRegistrationProvider,
                       instanceProvider,
                       tryConstructArguments,
                       requireAttributes,
                       attributeTypes));
        }