Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="property"></param>
        /// <returns></returns>
        public static string GetParameterName(PropertyDescriptor property)
        {
            DbFieldAttribute attribute =
                property.Attributes[_TypeOf_Field] as DbFieldAttribute;

            if (attribute != null)
            {
                return(attribute.ParameterName);
            }
            throw ParameterNotExists(string.Format("for property: {0}", property.Name), property.GetType());
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="parameterName"></param>
        /// <returns></returns>
        public static PropertyDescriptor FindPropertyByParameter(Type type, string parameterName)
        {
            DbFieldAttribute attribute = null;

            foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(type))
            {
                attribute = (DbFieldAttribute)property.Attributes[_TypeOf_Field];
                if (attribute != null && attribute.ParameterName == parameterName)
                {
                    return(property);
                }
            }
            throw ParameterNotExists(parameterName, type);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static PropertyDescriptor FindPropertyByField(Type type, string fieldName)
        {
            DbFieldAttribute attribute = null;

            fieldName = fieldName.ToLower();
            foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(type))
            {
                attribute = (DbFieldAttribute)property.Attributes[_TypeOf_Field];
                if (attribute != null && attribute.FieldName.ToLower() == fieldName)
                {
                    return(property);
                }
            }
            throw FieldNotExists(fieldName, type);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static IList <string> GetAllParameters(Type type)
        {
            DbFieldAttribute attribute = null;
            List <string>    list      = new List <string>();

            foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(type))
            {
                attribute = property.Attributes[_TypeOf_Field] as DbFieldAttribute;
                if (attribute != null)
                {
                    list.Add(attribute.ParameterName);
                }
            }
            return(list);
        }