public Func<object, object> CreateBindingDelegate(Type requestType, ServiceRequestBinderContext context)
		{
			IServiceRequestBinder binder = this.serviceRequestBinders.FirstOrDefault(x => x.CanCreateBindingDelegateFor(requestType));
			if (binder == null)
			{
				throw new ArgumentException(
					"Type " + requestType + " cannot be bound from a request to a DTO as its type is unknown",
					"requestType");
			}

			return binder.CreateBindingDelegate(requestType, context);
		}
		public Func<object, object> CreateBindingDelegate(Type requestType, ServiceRequestBinderContext context)
		{
			if (!this.CanCreateBindingDelegateFor(requestType))
				throw new ArgumentException("Type " + requestType + " must be a concrete class", "requestType");

			MethodInfo binder = this.nancyModelBinder.MakeGenericMethod(requestType);
			ParameterExpression requestParameters = Expression.Parameter(typeof(object), "requestParameters");
			return Expression.Lambda<Func<object, object>>(
				Expression.Call(
					binder,
					Expression.Constant(context.NancyModule, typeof(NancyModule))),
				requestParameters).Compile();
		}
Exemple #3
0
        public Func <object, object> CreateBindingDelegate(Type requestType, ServiceRequestBinderContext context)
        {
            IServiceRequestBinder binder = this.serviceRequestBinders.FirstOrDefault(x => x.CanCreateBindingDelegateFor(requestType));

            if (binder == null)
            {
                throw new ArgumentException(
                          "Type " + requestType + " cannot be bound from a request to a DTO as its type is unknown",
                          "requestType");
            }

            return(binder.CreateBindingDelegate(requestType, context));
        }
Exemple #4
0
        public Func <object, object> CreateBindingDelegate(Type requestType, ServiceRequestBinderContext context)
        {
            if (!this.CanCreateBindingDelegateFor(requestType))
            {
                throw new ArgumentException("Type " + requestType + " must be a concrete class", "requestType");
            }

            MethodInfo          binder            = this.nancyModelBinder.MakeGenericMethod(requestType);
            ParameterExpression requestParameters = Expression.Parameter(typeof(object), "requestParameters");

            return(Expression.Lambda <Func <object, object> >(
                       Expression.Call(
                           binder,
                           Expression.Constant(context.NancyModule, typeof(NancyModule))),
                       requestParameters).Compile());
        }