Inheritance: CObjectSerializer
コード例 #1
0
        /// <summary>
        /// Gets the serializer-Instance according to given type
        /// </summary>
        /// <param name="type">Type of the objects, that have to be serialized</param>
        /// <returns>Serializer - Instance</returns>
        public AbstractSerializer GetSerializer(Type type)
        {
            object val;

            if (type == typeof(decimal?) || type == typeof(decimal))
            {
                int a = 10;
            }
            AbstractSerializer abstractSerializer = null;

            if (!m_htSerializerMap.TryGetValue(type, out val))
            {
                // TODO: Serialisieren von Nullbaren Typen und generischen
                // Listen
                if (typeof(IDictionary).IsAssignableFrom(type))
                {
                    abstractSerializer = new CMapSerializer();
                }
                else if (type.IsArray)
                {
                    abstractSerializer = new CArraySerializer();
                }
                else if (typeof(IList).IsAssignableFrom(type))
                {
                    abstractSerializer = new CCollectionSerializer();
                }
                else if (typeof(Stream).IsAssignableFrom(type))
                {
                    abstractSerializer = new CInputStreamSerializer();
                }
                else if (typeof(Exception).IsAssignableFrom(type))
                {
                    abstractSerializer = new CExceptionSerializer();
                }

                else if (type.IsEnum)
                {
                    abstractSerializer = new CEnumSerializer();
                }
                else
                {
                    if (m_htCachedSerializerMap.TryGetValue(type.FullName, out val))
                    {
                        abstractSerializer = (AbstractSerializer)val;
                    }
                    else
                    {
                        abstractSerializer = new CObjectSerializer(type);
                        m_htCachedSerializerMap.Add(type.FullName, abstractSerializer);
                    }
                }
            }
            else
            {
                abstractSerializer = (AbstractSerializer)val;
            }
            return(abstractSerializer);
        }
コード例 #2
0
        public CExceptionDeserializer(Type type) : base(type)
        {
            List <Object> fieldList = CExceptionSerializer.GetSerializableFields();

            foreach (FieldInfo fieldInfo in fieldList)
            {
                m_deserFields[fieldInfo.Name] = fieldInfo;
            }
            m_type = type;
        }
コード例 #3
0
        public CExceptionDeserializer(Type type) : base(type)
        {
            List <Object> propertyList = CExceptionSerializer.GetSerializablePropertys();

            foreach (PropertyInfo propertyInfo in propertyList)
            {
                m_deserPropertys[propertyInfo.Name] = propertyInfo;
            }
            m_type = type;
        }