You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
714 B
C#

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<string, object> ToDictionary(this object obj)
{
var dictionary = new Dictionary<string, object>();
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;
}
}
}