Example #1
0
        private Delegate BuildDelegate(Expression expression)
        {
            try
            {
                return(CompilationHelpers.CompileExpression(this.ImplementationType, this.Container, expression));
            }
            catch (Exception ex)
            {
                string message = StringResources.ErrorWhileBuildingDelegateFromExpression(
                    this.ImplementationType, expression, ex);

                throw new ActivationException(message, ex);
            }
        }
Example #2
0
        private Func <TService> BuildDelegate <TService>(Expression expression)
            where TService : class
        {
            try
            {
                return(CompilationHelpers.CompileExpression <TService>(this.Container, expression));
            }
            catch (Exception ex)
            {
                string message = StringResources.ErrorWhileBuildingDelegateFromExpression(
                    typeof(TService), expression, ex);

                throw new ActivationException(message, ex);
            }
        }
        private Func <object> BuildInstanceCreator()
        {
            // Don't do recursive checks. The GetInstance() already does that.
            var expression = this.expression.Value;

            try
            {
                return(CompilationHelpers.CompileExpression <object>(this.Registration.Container, expression));
            }
            catch (Exception ex)
            {
                string message =
                    StringResources.ErrorWhileBuildingDelegateFromExpression(this.ServiceType, expression, ex);

                throw new ActivationException(message, ex);
            }
        }
        private Func <object> BuildInstanceCreator()
        {
            // Don't do recursive checks. The GetInstance() already does that.
            var expression = this.lazyExpression.Value;

            Func <object> creator;

            try
            {
                creator = CompilationHelpers.CompileExpression <object>(this.Container, expression);
                creator = this.Container.WrapWithResolveInterceptor(this, creator);
            }
            catch (Exception ex)
            {
                string message =
                    StringResources.ErrorWhileBuildingDelegateFromExpression(this.ServiceType, expression, ex);

                throw new ActivationException(message, ex);
            }

            this.Analyze();

            return(creator);
        }