Example #1
0
        /// <summary>
        /// Convers the to.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <returns>An IRecord.</returns>
        public IRecord ConverTo(T1 obj)
        {
            var properties = t1Type.GetProperties();
            var record     = new Record();

            foreach (var item in properties)
            {
                var value = PropertyGetDelegateCache.TryGet(item, obj);
                record[item.Name] = value;
            }
            return(record);
        }
Example #2
0
        /// <summary>
        /// Convers the to.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns>A T2.</returns>
        public T2 ConverTo(T1 model)
        {
            var properties   = t1Type.GetProperties();
            var t2Properties = t2Type.GetProperties();
            var t2           = new T2();

            foreach (var item in properties)
            {
                if (!t2Properties.Any(t => t.Name == item.Name))
                {
                    continue;
                }
                var value = PropertyGetDelegateCache.TryGet(item, model);
                PropertySetDelegateCache.TrySet(item, t2, value);
            }
            return(t2);
        }