/// <summary>
 /// 使用PropertyDescriptor映射(或IDataRowSetter接口,如果对象实IDataRowSetter接口)设置属性值
 /// </summary>
 /// <param name="des"></param>
 /// <param name="propertyname"></param>
 /// <param name="propertyvalue"></param>
 public static void SetMemberValue(this object des, string membername, object membervalue)
 {
     if (des == null)
     {
         return;
     }
     try
     {
         if (des is IDataRowSetter)
         {
             IDataRowSetter s = des as IDataRowSetter;
             s.SetFieldValue(membername, membervalue);
             return;
         }
         PropertyDescriptorCollection pdcols = TypeDescriptor.GetProperties(des);
         PropertyDescriptor           pd     = pdcols[membername];
         if (pd != null)
         {
             if (membervalue != null && pd.PropertyType.IsNullableType() && pd.PropertyType.GetTypeIfIsNullable().IsEnum)
             {
                 //防止 从int类型到enum?类型的转换无效错误
                 object v = Enum.ToObject(pd.PropertyType.GetTypeIfIsNullable(), membervalue);
                 pd.SetValue(des, v);
             }
             else
             {
                 pd.SetValue(des, membervalue);
             }
         }
     }
     catch (Exception e)
     {
         throw new UnkownCodeException(ErrorCodes.SetMemberValueError, string.Format(LocalResource.SetMemberValueError, des.GetType().FullName, membername, e.Message));
     }
 }
        /// <summary>
        /// 设置数据data的字段值为fieldvalue
        /// <para>如果data实现接口IDataRowSetter,则调用IDataRowSetter.SetFieldValue</para>
        /// </summary>
        /// <param name="field"></param>
        /// <param name="data">要设置值的数据</param>
        /// <param name="fieldvalue">要设置为的字段值</param>
        public static void SetModelFieldValue(this IDataFieldModel field, object data, object fieldvalue)
        {
            if (data is IDataRowSetter)
            {
                IDataRowSetter s = data as IDataRowSetter;
                s.SetFieldValue(field.Name, fieldvalue);
                return;
            }
            PropertyDescriptor pd = DataModelHelper.GetExtendProerty_PropertyDescription(field.InnerExtend);

            if (pd != null)
            {
                pd.SetValue(data, fieldvalue);
            }
            else
            {
                throw new ObjectIsNullException(LocalResource.FieldPropertyDescriptor);
            }
        }