مروری بر کاربردهای Anonymous Types
نویسنده: وحید نصیری
تاریخ: ۱۳۹۱/۰۴/۰۳ ۰:۵۶
آدرس: www.dntips.ir
public static RouteValueDictionary AnonymousObjectToHtmlAttributes(object htmlAttributes) {
RouteValueDictionary result = new RouteValueDictionary();
if (htmlAttributes != null) {
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(htmlAttributes)) {
result.Add(property.Name.Replace('_', '-'), property.GetValue(htmlAttributes));
}
}
return result;
}