public object Deserialize(Type objectType, DTObject dto)
        {
            if (objectType == typeof(DTObject))
            {
                return(dto);
            }
            TypeMakupInfo typeInfo = TypeMakupInfo.GetTypeInfo(objectType);

            return(typeInfo.Deserialize(dto));
        }
Ejemplo n.º 2
0
        public T Deserialize <T>(DTObject obj)
        {
            var targetType = typeof(T);

            if (targetType == typeof(DTObject))
            {
                return((T)((object)obj));
            }
            TypeMakupInfo typeInfo = TypeMakupInfo.GetTypeInfo(targetType);

            return((T)typeInfo.Deserialize(obj));
        }
        public DTObject Serialize(object instance, bool isPinned)
        {
            //if (instance == null) return DTObject.Create("{null}");   老代码,暂时保留
            if (instance == null)
            {
                return(DTObject.Empty);
            }
            var instanceType = instance.GetType();

            if (instanceType == typeof(DTObject))
            {
                return((DTObject)instance);
            }
            TypeMakupInfo typeInfo = TypeMakupInfo.GetTypeInfo(instanceType);

            return(typeInfo.Serialize(instance, isPinned));
        }
        /// <summary>
        /// 将dto的内容反序列化到<paramref name="instance"/>
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="dto"></param>
        public void Deserialize(object instance, DTObject dto)
        {
            TypeMakupInfo typeInfo = TypeMakupInfo.GetTypeInfo(instance.GetType());

            typeInfo.Deserialize(instance, dto);
        }