Пример #1
0
        /// <summary>
        /// Convers the to.
        /// </summary>
        /// <param name="read"></param>
        /// <returns>A T1.</returns>
        public T1 ConverTo(IGetValue read)
        {
            var properties = t1Type.GetProperties();
            var t1         = new T1();

            foreach (var item in properties)
            {
                var value = read.GetValue(item.Name);
                if (value == null)
                {
                    continue;
                }
                PropertySetDelegateCache.TrySet(item, t1, value);
            }
            return(t1);
        }
Пример #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);
        }