Ejemplo n.º 1
0
        public T GetObject <T>(DataRow item)
        {
            var properties = typeof(T).GetProperties();
            var result     = _structureMapWrapper.GetInstance(typeof(T));

            foreach (
                var property in
                properties.Where(
                    property =>
                    typeof(T).GetProperty(property.Name).GetCustomAttribute(typeof(IgnoreAttribute), false) ==
                    null))
            {
                property.SetValue(result, property.PropertyType.BaseType == typeof(Enum)
                    ? EnumParser.GetEnumFromValue(item[property.Name].ToString(), property.PropertyType)
                    : CleanInput(item[property.Name], property.PropertyType));
            }

            return((T)result);
        }