コード例 #1
0
        public object Deserialize(Type objectType, DTObject dto)
        {
            if (objectType == typeof(DTObject))
            {
                return(dto);
            }
            TypeMakupInfo typeInfo = TypeMakupInfo.GetTypeInfo(objectType);

            return(typeInfo.Deserialize(dto));
        }
コード例 #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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        /// <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);
        }