Skip to content

Commit 1e9f379

Browse files
authored
Merge pull request #60 from zzxiang/empty-array
Allowed empty cells for non-enum array types in Google Spreadsheets.
2 parents 4f092d5 + 8b6de5c commit 1e9f379

File tree

1 file changed

+10
-8
lines changed
  • Assets/QuickSheet/GDataPlugin/Editor/GDataDB/GDataDB/Impl

1 file changed

+10
-8
lines changed

Assets/QuickSheet/GDataPlugin/Editor/GDataDB/GDataDB/Impl/Serializer.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,19 @@ public T Deserialize(ListEntry e) {
9595
char[] charToTrim = { ',', ' ' };
9696
str = str.TrimEnd(charToTrim);
9797

98-
// split by ','
99-
object[] temp = str.Split(DELIMETER);
98+
if (!string.IsNullOrEmpty(str)) {
99+
// split by ','
100+
object[] temp = str.Split(DELIMETER);
100101

101-
Array array = (Array)Activator.CreateInstance(property.PropertyType, temp.Length);
102+
Array array = (Array)Activator.CreateInstance(property.PropertyType, temp.Length);
102103

103-
for (int i = 0; i < array.Length; i++)
104-
{
105-
array.SetValue(Convert.ChangeType(temp[i], property.PropertyType.GetElementType()), i);
106-
}
104+
for (int i = 0; i < array.Length; i++)
105+
{
106+
array.SetValue(Convert.ChangeType(temp[i], property.PropertyType.GetElementType()), i);
107+
}
107108

108-
property.SetValue(r, array, null);
109+
property.SetValue(r, array, null);
110+
}
109111
}
110112
}
111113
else

0 commit comments

Comments
 (0)