Exemplo n.º 1
0
        private IResolver CreateResolverByExpression
            (IServiceDefinition definition, Expression <Func <ServiceRequest, object> > expression)
        {
            if (expression.Body is NewExpression nex)
            {
                expression = _configuration.Options.ExpressionBuilder
                             .CreateResolutionExpressionFromConstructorExpression(nex);
            }
            var resolver = new ExpressionResolver(definition, expression, InstanceType);

            return(BuildUp(resolver, definition, true));
        }
Exemplo n.º 2
0
        private IResolver CreateResolverByType(IServiceDefinition definition, Type implementationType)
        {
            var constructor = _configuration.Options.ConstructorSelector.SelectConstructor
                                  (implementationType, _configuration);

            if (constructor == null)
            {
                return(new NonResolver(InstanceType));
            }
            var expression =
                _configuration.Options.ExpressionBuilder.CreateResolutionExpressionFromDefaultConstructor(constructor);
            var isTracked = typeof(IDisposable).IsAssignableFrom(implementationType);
            var resolver  = new ExpressionResolver(definition, expression, InstanceType);

            return(BuildUp(resolver, definition, isTracked));
        }