コード例 #1
0
        /// <summary>Marks the registration as having a specific constructor parameter discovered by type, whose value is resolved by the container (when given the name of the service). </summary>
        /// <typeparam name="T">The type of the service to resolve in order to pass in as the value of the parameter.</typeparam>
        /// <returns>.</returns>
        public IServiceRegistrarModifier <TContract, TImplementation> WithResolvedParam <T>(string serviceName)
        {
            var resolver = new NinjectResolver(_bindingResult.Kernel);

            _bindingResult.WithConstructorArgument(null, defer => resolver.Resolve <T>());
            return(this);
        }
コード例 #2
0
        /// <summary>Marks the registration as having a specific constructor parameter discovered by type, whose value is resolved by the container (when given the name of the service). </summary>
        /// <typeparam name="T">The type of the service to resolve in order to pass in as the value of the parameter.</typeparam>
        /// <returns>.</returns>
        public IRuntimeTypeRegistrarModifier <TContract> WithResolvedParam <T>(string serviceName)
        {
            NinjectResolver resolver   = new NinjectResolver(_bindingResult.Kernel);
            var             paramValue = resolver.Resolve <T>(serviceName);

            _bindingResult.WithConstructorArgument(null, paramValue);
            return(this);
        }
コード例 #3
0
 /// <summary>Resolves a service given the required contract type.</summary>
 /// <typeparam name="T">The type with which the service implementation was registered.</typeparam>
 /// <returns>An instance of type <typeparamref name="T"/>.</returns>
 public T Resolve <T>()
 {
     return(_resolver.Resolve <T>());
 }