AutomaticPropertiesDefaultValues
Article_src.zip
PropertyInfo[] props = o.GetType().GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)
for (int i = 0 i < props.Length i++)
{
PropertyInfo prop = props[i]
if (prop.GetCustomAttributes(true).Length > 0)
{
object[] defaultValueAttribute = prop.GetCustomAttributes(typeof(DefaultValueAttribute), true)
if (defaultValueAttribute != null)
{
DefaultValueAttribute dva = defaultValueAttribute[0] as DefaultValueAttribute
if(dva != null)
prop.SetValue(o, dva.Value, null)
}
标签:
AutomaticPropertiesDefaultValues
PropertyInfo
Article_src
GetPropert
上传时间:
2014-11-22
上传用户:xaijhqx