Esempio n. 1
0
        public static Dictionary <string, object> GetPropertyValues(object entity)
        {
            var dictionary = new Dictionary <string, object>();

            foreach (var pair in ExpressionReflector.GetGetters(entity.GetType()))
            {
                dictionary.Add(pair.Key, pair.Value(entity));
            }
            return(dictionary);
        }
Esempio n. 2
0
        public static void Map <TSource, TTarget>(TSource source, TTarget target)
        {
            var entityType = typeof(TTarget);
            var getters    = ExpressionReflector.GetGetters(typeof(TSource));
            var setters    = ExpressionReflector.GetSetters(entityType);

            foreach (var str in getters.Keys)
            {
                if (setters.ContainsKey(str))
                {
                    setters[str](target, getters[str](source));
                }
            }
        }