예제 #1
0
        /// <summary>
        /// Adds a query string parameter to the Uri.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="property">The property.</param>
        /// <param name="value">The property value.</param>
        /// <returns>Itself</returns>
        public NavigateHelper <TViewModel> WithParam <TValue>(Expression <Func <TViewModel, TValue> > property, TValue value)
        {
            if (value is ValueType || !ReferenceEquals(null, value))
            {
                _parameters[PropertySupport.ExtractPropertyName(property)] = value.ToString();
            }

            return(this);
        }
        /// <summary>
        /// Sets the property to listen for change notifications.
        /// </summary>
        /// <param name="target">The object to observe.</param>
        /// <param name="property">The property.</param>
        /// <returns>Itself</returns>
        public DelegateCommandBuilder Observe <TProperty>(INotifyPropertyChanged target, Expression <Func <TProperty> > property)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            if (_target != null)
            {
                throw new InvalidOperationException("Observe already set.");
            }
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }

            var propertyName = PropertySupport.ExtractPropertyName(property);

            _target        = target;
            _propertyNames = new[] { propertyName };
            return(this);
        }
예제 #3
0
 /// <summary>
 /// Raises the PropertyChanged event if needed.
 /// </summary>
 /// <typeparam name = "TProperty">The type of the property.</typeparam>
 /// <param name = "property">The property expression.</param>
 protected void RaisePropertyChanged <TProperty>(Expression <Func <TProperty> > property)
 {
     RaisePropertyChanged(PropertySupport.ExtractPropertyName(property));
 }
예제 #4
0
        /// <summary>
        /// Validates the property.
        /// </summary>
        /// <typeparam name="TProperty">The type of the property.</typeparam>
        /// <param name="property">The property.</param>
        /// <param name="value">The value to validate.</param>
        /// <returns>True, if validation succeeded.</returns>
        public bool ValidateProperty <TProperty>(Expression <Func <TProperty> > property, object value)
        {
            var propertyName = PropertySupport.ExtractPropertyName(property);

            return(ValidateProperty(propertyName, value));
        }
예제 #5
0
        /// <summary>
        /// Determines whether the spezified property has validation errors.
        /// </summary>
        /// <typeparam name="TProperty">The type of the property.</typeparam>
        /// <param name="property">The property.</param>
        /// <returns>True, if the property has validation errors.</returns>
        public bool HasPropertyError <TProperty>(Expression <Func <TProperty> > property)
        {
            var propertyName = PropertySupport.ExtractPropertyName(property);

            return(HasPropertyError(propertyName));
        }
예제 #6
0
        /// <summary>
        /// Gets all validation errors of the spezified property.
        /// </summary>
        /// <typeparam name="TProperty">The type of the property.</typeparam>
        /// <param name="property">The property.</param>
        /// <returns>List of validation errors.</returns>
        public IEnumerable <string> GetPropertyError <TProperty>(Expression <Func <TProperty> > property)
        {
            var propertyName = PropertySupport.ExtractPropertyName(property);

            return(GetPropertyError(propertyName));
        }
예제 #7
0
        /// <summary>
        /// Removes all validation rules for a property.
        /// </summary>
        /// <typeparam name="TProperty">The type of the property.</typeparam>
        /// <param name="property">The property.</param>
        public void RemoveRules <TProperty>(Expression <Func <TProperty> > property)
        {
            var propertyName = PropertySupport.ExtractPropertyName(property);

            RemoveRules(propertyName);
        }
예제 #8
0
        /// <summary>
        /// Adds a <see cref="IValidationRule"/> to the validator.
        /// </summary>
        /// <typeparam name="TProperty">The type of the property.</typeparam>
        /// <param name="property">The property.</param>
        /// <param name="rule">The rule to add.</param>
        public void AddRule <TProperty>(Expression <Func <TProperty> > property, IValidationRule rule)
        {
            var propertyName = PropertySupport.ExtractPropertyName(property);

            AddRule(propertyName, rule);
        }