Example #1
0
        /// <summary>
        /// Try to resolve the value from the model
        /// </summary>
        /// <typeparam name="TModel">The type of the model.</typeparam>
        /// <param name="modelProperties">The model properties.</param>
        /// <param name="model">The model.</param>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public override bool TryResolveValue <TModel>(IModelProperties <TModel> modelProperties, TModel model, out string value)
        {
            bool resolved = modelProperties.TryGetPropertyValue(model, Name, out value);

            if (resolved && (value == "0"))
            {
                value = null;
                return(false);
            }
            return(resolved);
        }
Example #2
0
        public bool Validate(IModelProperties <TModel> modelProperties, TModel model, ValidationMessages validationMessages)
        {
            string location;

            bool isValid = true;

            if (modelProperties.TryGetPropertyValue(model, "Location", out location))
            {
                isValid = !string.IsNullOrEmpty(location);
                if (!isValid)
                {
                    string message = string.Format("The Location property is not specified. Type='{0}'", typeof(TModel));
                    validationMessages.Add(message);
                }
            }
            return(isValid);
        }
        public bool Bind()
        {
            if (model == null)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(idProperty))
            {
                return(false);
            }

            string value;

            modelProperties.TryGetPropertyValue(model, idProperty, out value);
            identifiers.Add(Convert.ToInt32(value));

            return(true);
        }
Example #4
0
 /// <summary>
 /// Try to resolve the value from the model
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <param name="modelProperties"></param>
 /// <param name="model"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public override bool TryResolveValue <TModel>(IModelProperties <TModel> modelProperties, TModel model, out string value)
 {
     return(modelProperties.TryGetPropertyValue(model, Name, out value));
 }