- private bool IsAllPropertyNull<T>(T fac)
- {
- bool isnull = true;
- T ts = fac;
- PropertyInfo[] pi = ts.GetType().GetProperties();
- foreach (PropertyInfo p in pi)
- {
- object pvalue = p.GetValue(fac, null);
- if (pvalue is int)
- if ((int)pvalue != 0)
- {
- isnull = false;
- break;
- }
- if (pvalue is string)
- if (pvalue != null)
- {
- isnull = false;
- break;
- }
- }
- return isnull;
- }
- //该片段来自于http://www.codesnippet.cn/detail/0704201512132.html
来源: http://www.codesnippet.cn/detail/0704201512132.html