protected PropertyExpression(object obj, IEnumerable<PropertyExpressionPart> parts)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");
            if (parts == null)
                throw new ArgumentNullException("parts");
            /*foreach (object item in parts)
            {
                if (item == null)
                {
                    throw new ArgumentException("An item inside the enumeration was null.", "parts");
                }
            }*/
            if (parts.Cast<object>().Any(item => item == null))
            {
                throw new ArgumentException(Resources.AnItemWasNull, "parts");
            }

            _parts = new List<PropertyExpressionPart>(parts);

            if (_parts.Count == 0)
                throw new ArgumentException(Resources.OnePartRequired, "parts");

            _finalPart = _parts.Last();
            //whenever the final part's value changes, that means the value of the expression as a whole has changed
            _finalPart.ValueChanged += delegate
                {
                    OnValueChanged();
                };

            //assign the initial object in the potential chain of objects resolved by the expression parts
            _parts[0].Object = obj;
        }
        protected PropertyExpression(object obj, IEnumerable <PropertyExpressionPart> parts)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            if (parts == null)
            {
                throw new ArgumentNullException("parts");
            }

            /*foreach (object item in parts)
             * {
             *  if (item == null)
             *  {
             *      throw new ArgumentException("An item inside the enumeration was null.", "parts");
             *  }
             * }*/
            if (parts.Cast <object>().Any(item => item == null))
            {
                throw new ArgumentException(Resources.AnItemWasNull, "parts");
            }

            _parts = new List <PropertyExpressionPart>(parts);

            if (_parts.Count == 0)
            {
                throw new ArgumentException(Resources.OnePartRequired, "parts");
            }

            _finalPart = _parts.Last();
            //whenever the final part's value changes, that means the value of the expression as a whole has changed
            _finalPart.ValueChanged += delegate
            {
                OnValueChanged();
            };

            //assign the initial object in the potential chain of objects resolved by the expression parts
            _parts[0].Object = obj;
        }
 /// <summary>
 /// Constructs an instance of <c>PropertyExpressionPart</c>.
 /// </summary>
 /// <param name="nextPart">The next part in the chain of parts held in the <see cref="PropertyExpression" />.</param>
 /// <param name="bindOnValidation">if set to <c>true</c> the bound value should be updated on property validation.</param>
 protected PropertyExpressionPart(PropertyExpressionPart nextPart, bool bindOnValidation)
 {
     _nextPart = nextPart;
     _object = new WeakReference(null);
     _bindOnValidation = bindOnValidation;
 }
Example #4
0
 /// <summary>
 /// Constructs an instance of <c>PropertyExpressionPart</c>.
 /// </summary>
 /// <param name="nextPart">The next part in the chain of parts held in the <see cref="PropertyExpression" />.</param>
 /// <param name="bindOnValidation">if set to <c>true</c> the bound value should be updated on property validation.</param>
 protected PropertyExpressionPart(PropertyExpressionPart nextPart, bool bindOnValidation)
 {
     _nextPart         = nextPart;
     _object           = new WeakReference(null);
     _bindOnValidation = bindOnValidation;
 }