Ejemplo n.º 1
0
        /// <summary>
        /// 转换IDataObject对象类型
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="objInput"></param>
        /// <returns></returns>
        public static T ChangeType <T>(IDataObject objInput) where T : IDataObject, new()
        {
            T t = new T();

            Dictionary <string, MemberInfo> oldType = EntityTools.GetFieldListFromCache(objInput.GetType());

            foreach (string s in oldType.Keys)
            {
                try
                {
                    object o = objInput.GetValue(s);

                    if (o != null)
                    {
                        t.SetValue(s, o);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "IDataObject转换类型错误");
                }
            }

            return(t);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 在两个IDataObject对象之间传递数据
        /// </summary>
        /// <param name="objInput"></param>
        /// <param name="objOutput"></param>
        /// <returns></returns>
        public static void ChangeType(IDataObject objInput, IDataObject objOutput)
        {
            Dictionary <string, MemberInfo> oldType = EntityTools.GetFieldListFromCache(objInput.GetType());

            foreach (string s in oldType.Keys)
            {
                try
                {
                    object o = objInput.GetValue(s);

                    if (o != null)
                    {
                        objOutput.SetValue(s, o);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "IDataObject转换类型错误");
                }
            }
        }