public override object GetValue()
        {
            if (_property == null)
            {
                return(null);
            }

            object instance = _target.GetValue();

            if (NullHelper.IsNull(instance))
            {
                return(null);
            }

            object result;

            try
            {
                result = _property.GetValue(instance);
            }
            catch (NQueryException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw ExceptionBuilder.PropertyBindingGetValueFailed(ex);
            }

            return(NullHelper.UnifyNullRepresentation(result));
        }
        public override object GetValue()
        {
            if (_method == null)
            {
                return(null);
            }

            object targetValue = _target.GetValue();

            if (NullHelper.IsNull(targetValue))
            {
                return(null);
            }

            object[] argumentValues = new object[_arguments.Length];

            for (int i = 0; i < argumentValues.Length; i++)
            {
                argumentValues[i] = _arguments[i].GetValue();
            }

            object result;

            try
            {
                result = _method.Invoke(targetValue, argumentValues);
            }
            catch (TargetInvocationException ex)
            {
                // Special handling for target invocation since we are only
                // interested in the inner one.
                throw ExceptionBuilder.MethodBindingInvokeFailed(ex.InnerException);
            }
            catch (NQueryException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw ExceptionBuilder.MethodBindingInvokeFailed(ex);
            }

            return(NullHelper.UnifyNullRepresentation(result));
        }
        public override object GetValue()
        {
            if (_function == null)
            {
                return(null);
            }

            // BUG: Shouln't we ensure that all arguments are non-null?
            object[] argumentValues = new object[_arguments.Length];
            for (int i = 0; i < argumentValues.Length; i++)
            {
                argumentValues[i] = _arguments[i].GetValue();
            }

            object result;

            try
            {
                result = _function.Invoke(argumentValues);
            }
            catch (TargetInvocationException ex)
            {
                // Special handling for target invocation since we are only
                // interested in the inner one.

                if (ex.InnerException is NQueryException)
                {
                    throw ExceptionBuilder.RuntimeError(ex.InnerException);
                }

                throw ExceptionBuilder.FunctionBindingInvokeFailed(ex.InnerException);
            }
            catch (NQueryException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw ExceptionBuilder.FunctionBindingInvokeFailed(ex);
            }

            return(NullHelper.UnifyNullRepresentation(result));
        }
        public override object GetValue()
        {
            object result;

            try
            {
                result = _constantBinding.Value;
            }
            catch (NQueryException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw ExceptionBuilder.ConstantBindingGetValueFailed(ex);
            }

            return(NullHelper.UnifyNullRepresentation(result));
        }
Example #5
0
        public override object GetValue()
        {
            if (_parameter == null)
            {
                return(null);
            }

            object result;

            try
            {
                result = _parameter.Value;
            }
            catch (NQueryException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw ExceptionBuilder.ParameterBindingGetValueFailed(ex);
            }

            return(NullHelper.UnifyNullRepresentation(result));
        }