Exemple #1
0
        public IResult Bind(IBindingItemsCollection bindingItemsCollection)
        {
            if (null == bindingItemsCollection)
            {
                throw new ArgumentNullException("bindingItemsCollection");
            }
            BindingResult result = new BindingResult();

            foreach (IBindingItem item in bindingItemsCollection)
            {
                result.Concatenate(this.Bind(item));
            }
            return(result);
        }
Exemple #2
0
        public IResult Bind()
        {
            BindingResult result = new BindingResult();

            try
            {
                if (null == this._target)
                {
                    throw new MissingBindingElementException("target object");
                }
                if (string.IsNullOrEmpty(this._targetProperty))
                {
                    throw new MissingBindingElementException("target property name");
                }
                if (null == this._source)
                {
                    throw new MissingBindingElementException("source object");
                }
                if (string.IsNullOrEmpty(this._sourceProperty))
                {
                    throw new MissingBindingElementException("source property name");
                }

                if (null == this.Expression ||
                    (null != this.ExpressionEvaluationResult && this.ExpressionEvaluationResult.IsSuccessful()) ||
                    (null == this.ExpressionEvaluationResult && this.Expression.Evaluate().IsSuccessful()))
                {
                    object val = this.ExtractValue(this._source, this._sourceProperty);
                    if ((val == null || (val is string && string.IsNullOrEmpty((string)val))) && null != this._defaultValue)
                    {
                        val = this._defaultValue;
                    }

                    this.SetValue(this._target, this._targetProperty, val);
                }

                result.Status = ResultStatus.Successful;
            }
            catch (Exception exception)
            {
                result.Status = ResultStatus.Unsuccessful;
                result.Exceptions.Add(exception);
            }
            return(result);
        }
Exemple #3
0
        public IResult Bind()
        {
            BindingResult result = new BindingResult();
            try
            {
                if (null == this._target) throw new MissingBindingElementException("target object");
                if (string.IsNullOrEmpty(this._targetProperty)) throw new MissingBindingElementException("target property name");
                if (null == this._source) throw new MissingBindingElementException("source object");
                if (string.IsNullOrEmpty(this._sourceProperty)) throw new MissingBindingElementException("source property name");

                if (null == this.Expression ||
                    (null != this.ExpressionEvaluationResult && this.ExpressionEvaluationResult.IsSuccessful()) ||
                    (null == this.ExpressionEvaluationResult && this.Expression.Evaluate().IsSuccessful()))
                {
                    object val = this.ExtractValue(this._source, this._sourceProperty);
                    if ((val == null || (val is string && string.IsNullOrEmpty((string)val))) && null != this._defaultValue)
                        val = this._defaultValue;

                    this.SetValue(this._target, this._targetProperty, val);
                }

                result.Status = ResultStatus.Successful;
            }
            catch (Exception exception)
            {
                result.Status = ResultStatus.Unsuccessful;
                result.Exceptions.Add(exception);
            }
            return result;
        }
Exemple #4
0
 public IResult Bind(IBindingItemsCollection bindingItemsCollection)
 {
     if (null == bindingItemsCollection)
     {
         throw new ArgumentNullException("bindingItemsCollection");
     }
     BindingResult result = new BindingResult();
     foreach (IBindingItem item in bindingItemsCollection)
     {
         result.Concatenate(this.Bind(item));
     }
     return result;
 }