コード例 #1
0
 public SerializeNode(Type type, NodeCategory nodeCategory, TypeNode typeNode = null,
                      CustomSerialierAttribute customAttr = null) : base(type)
 {
     Category        = nodeCategory;
     TypeNode        = typeNode;
     customAttribute = customAttr;
 }
コード例 #2
0
        public static SerializeNode Create(Type fieldType, CustomSerialierAttribute customAttribute = null)
        {
            var type = fieldType;

            if (type.IsArray)
            {
                return(new SerializeNode(type, NodeCategory.ARRAY, customAttr: customAttribute));
            }
            if (type == typeof(SerializableTimeSpan))
            {
                return(new SerializeNode(type, NodeCategory.TIMESPAN, customAttr: customAttribute));
            }
            if (type == typeof(DateTime))
            {
                return(new SerializeNode(type, NodeCategory.DATETIME, customAttr: customAttribute));
            }
            if (TypeUtil.IsSubclassOfDictionary(type))
            {
                return(new SerializeNode(type, NodeCategory.DICTIONARY, customAttr: customAttribute));
            }
            if (TypeUtil.IsSubclassOfList(type))
            {
                return(new SerializeNode(type, NodeCategory.LIST, customAttr: customAttribute));
            }
            if (TypeUtil.IsNullable(type))
            {
                return(new NullableSerializationNode(type, Create(TypeUtil.GetNullableValueType(type)), customAttribute));
            }
            if (type.IsPrimitive)
            {
                return(new SerializeNode(type, NodeCategory.PRIMITIVE, customAttr: customAttribute));
            }
            if (type.IsEnum)
            {
                return(new SerializeNode(type, NodeCategory.ENUM, customAttr: customAttribute));
            }
            if (XmlUtil.IsPolymorphicClass(type))
            {
                return(new SerializeNode(type, NodeCategory.POLY_CLASS, customAttr: customAttribute));
            }
            if (type.IsClass)
            {
                return(new SerializeNode(type, NodeCategory.CLASS, customAttr: customAttribute));
            }
            if (type.IsValueType)
            {
                return(new SerializeNode(type, NodeCategory.STRUCT, customAttr: customAttribute));
            }
            return(null);
        }
コード例 #3
0
 public NullableSerializationNode(Type type, SerializeNode subTypeNode, CustomSerialierAttribute customAttribute)
     : base(type, NodeCategory.NULLABLE, customAttr: customAttribute)
 {
     Serialize = subTypeNode;
 }
コード例 #4
0
 public FieldNode(Type type, FieldInfo field) : base(type)
 {
     this.field      = field;
     customAttribute = TypeUtil.GetCustomAttribute <CustomSerialierAttribute>(field, true);
 }
コード例 #5
0
 public TypeNode(RootType type) : base(type.Type)
 {
     rootType        = type;
     customAttribute = TypeUtil.GetCustomAttribute <CustomSerialierAttribute>(type.Type, true);
 }
コード例 #6
0
 public TypeNode(Type type, CustomSerialierAttribute customAttr = null) : base(type)
 {
     rootType        = new RootType(type, XmlUtil.IsPolymorphicClass(type));
     customAttribute = customAttr ?? TypeUtil.GetCustomAttribute <CustomSerialierAttribute>(type, true);
 }