protected override Expression VisitMember(MemberExpression node) { if (node.Member == null) { return(node); } object[] attrs = node.Member.GetCustomAttributes(typeof(ARFieldAttribute), true); if (attrs.Length > 1) { throw new CustomAttributeFormatException( string.Format("Mutiple ARFieldAttribute is found on Property : {0}.", node.Member.Name)); } if (attrs.Length == 0) { throw new CustomAttributeFormatException( string.Format("No ARFieldAttribute is found on Property : {0}.", node.Member.Name)); } ARFieldAttribute attr = (ARFieldAttribute)attrs.First(); uint arFieldId = attr.DatabaseID; if (arFieldId == default(uint)) { throw new CustomAttributeFormatException( string.Format("Invalid DatabaseId in ARFieldAttribute is found on Property : {0}.", node.Member.Name) ); } tr.Qulification.Append("'"); tr.Qulification.Append(arFieldId); tr.Qulification.Append("'"); return(node); }
private ARFieldAttribute GetARAttributeField(PropertyInfo pi, ModelBinderAccessLevel accessLevel) { if (pi == null) { throw new ArgumentNullException("pi"); } var attrs = pi.GetCustomAttributes(typeof(ARFieldAttribute), false); if (attrs.Length > 1) { throw new CustomAttributeFormatException( string.Format("Mutiple ARFieldAttribute is found on Property : {0}.", pi.Name)); } if (attrs.Length == 0) { return(null); } ARFieldAttribute attribute = attrs[0] as ARFieldAttribute; if (attribute.DatabaseID == 0) { throw new CustomAttributeFormatException( string.Format("DatabaseID of ARFieldAttribute on Property : {0} is missing.", pi.Name)); } if (attribute.DataType == ARType.None) { throw new CustomAttributeFormatException( string.Format("DataType of ARFieldAttribute on Property : {0} cannot be null.", pi.Name)); } if ((attribute.BinderAccess & accessLevel) == attribute.BinderAccess) { return(attribute); } else { return(null); } }