using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Reflection; namespace DSWeb.Areas.MvcShipping.DAL.MsCwVouchersGlDAL { public static class ObjectExtensions { public static Dictionary ToDictionary(this object obj) { var dictionary = new Dictionary(); if (obj == null) return dictionary; foreach (var property in obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) { var value = property.GetValue(obj); dictionary.Add(property.Name, value); } return dictionary; } } }