-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFieldData.cs
141 lines (114 loc) · 2.72 KB
/
FieldData.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
using System;
using System.Collections.Generic;
public class AraryFieldData
{
public string keyName;
public List<string> values;
}
public class ItemData
{
public int type;
public int id;
public int count;
}
public enum FieldObjectType
{
BOOLEAN = 1,
STRING = 2,
NUMBER = 3,
ITEM = 4,
ARRAY = 5,
INT_ARRAY = 6
}
public class FieldData
{
public string exportPlatform;
public string fieldName;
public Type fieldType;
public List<string> dataList = new List<string>(); //普通字段
public string fieldEnhanceType; //用额外一列来表示额外数据类型 方便对一些特定的类型进行特殊处理
public FieldObjectType objType;
public List<Object> objList = new List<Object>(); //对象列表根据 dataList 序列化后的字段
public void AddArrayField(string keyName, FieldData data)
{
if (objList == null)
{
objList = new List<Object>();
}
AraryFieldData adt = new AraryFieldData();
adt.keyName = keyName;
adt.values = data.dataList;
objList.Add(adt);
}
public int ObjListCount()
{
return objList.Count;
}
public AraryFieldData GetArrayFieldByIndex(int index)
{
if (objType != FieldObjectType.ARRAY)
{
return null;
}
if (index >= 0 && index < objList.Count)
{
return objList[index] as AraryFieldData;
}
return null;
}
public List<ItemData> GetItemDataListByIndex(int index)
{
if (objType != FieldObjectType.ITEM)
{
return null;
}
if (index >= 0 && index < objList.Count)
{
return objList[index] as List<ItemData>;
}
return null;
}
public void AddItemList(List<ItemData> itemList)
{
if (objList == null)
{
objList = new List<Object>();
}
objList.Add(itemList);
}
public void Add(string str)
{
dataList.Add(str);
}
public int RowCount
{
get { return dataList.Count; }
}
public string GetString(int rowIndex)
{
if (rowIndex >= 0 && rowIndex < dataList.Count)
{
return dataList[rowIndex];
} else
{
return "";
}
}
public bool CanExportTo(string plat)
{
return exportPlatform.IndexOf(plat) >= 0;
}
public FieldData()
{
}
public void CheckRealRowCount()
{
for (var i = dataList.Count - 1; i >= ExcelSheetData.DATA_START_ROW_INDEX; i--)
{
if (dataList[i] == "")
{
dataList.RemoveAt(i);
}
}
}
}