private static IEnumerable <BindingMemberInfo> GetBindingMembers(Type modelType, Type genericType, IEnumerable <string> blackList)
        {
            var blackListHash = new HashSet <string>(blackList, StringComparer.Ordinal);

            return(BindingMemberInfo.Collect(genericType ?? modelType)
                   .Where(member => !blackListHash.Contains(member.Name)));
        }
        /// <summary>
        /// Compares two BindingMemberInfo's with eachother on their respective values rather then their reference
        /// </summary>
        /// <param name="obj">the other BindingMemberInfo</param>
        /// <returns>true when they are equal and false otherwise</returns>
        public bool Equals(BindingMemberInfo obj)
        {
            if (obj == null)
            {
                return(false);
            }

            return(this.MemberInfo.Equals(obj.MemberInfo));
        }
        private static void BindValue(BindingMemberInfo modelProperty, string stringValue, BindingContext context, object targetInstance)
        {
            var destinationType = modelProperty.PropertyType;

            var typeConverter =
                context.TypeConverters.FirstOrDefault(c => c.CanConvertTo(destinationType, context));

            if (typeConverter != null)
            {
                try
                {
                    SetBindingMemberValue(modelProperty, targetInstance, typeConverter.Convert(stringValue, destinationType, context));
                }
                catch (Exception e)
                {
                    throw new PropertyBindingException(modelProperty.Name, stringValue, e);
                }
            }
            else if (destinationType == typeof(string))
            {
                SetBindingMemberValue(modelProperty, targetInstance, stringValue);
            }
        }
 private static void SetBindingMemberValue(BindingMemberInfo modelProperty, object model, object value)
 {
     // TODO - catch reflection exceptions?
     modelProperty.SetValue(model, value);
 }
 private static void BindValue(BindingMemberInfo modelProperty, string stringValue, BindingContext context)
 {
     BindValue(modelProperty, stringValue, context, context.Model);
 }
        private static void CopyValue(BindingMemberInfo modelProperty, object source, object destination)
        {
            var newValue = modelProperty.GetValue(source);

            modelProperty.SetValue(destination, newValue);
        }
 private bool BindingValueIsValid(string bindingValue, object existingValue, BindingMemberInfo modelProperty, BindingContext bindingContext)
 {
     return(!string.IsNullOrEmpty(bindingValue) &&
            (IsDefaultValue(existingValue, modelProperty.PropertyType) ||
             bindingContext.Configuration.Overwrite));
 }