Skip to content

Commit

Permalink
Merge pull request #60 from zzxiang/empty-array
Browse files Browse the repository at this point in the history
Allowed empty cells for non-enum array types in Google Spreadsheets.
  • Loading branch information
kimsama authored May 7, 2018
2 parents 4f092d5 + 8b6de5c commit 1e9f379
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,19 @@ public T Deserialize(ListEntry e) {
char[] charToTrim = { ',', ' ' };
str = str.TrimEnd(charToTrim);

// split by ','
object[] temp = str.Split(DELIMETER);
if (!string.IsNullOrEmpty(str)) {
// split by ','
object[] temp = str.Split(DELIMETER);

Array array = (Array)Activator.CreateInstance(property.PropertyType, temp.Length);
Array array = (Array)Activator.CreateInstance(property.PropertyType, temp.Length);

for (int i = 0; i < array.Length; i++)
{
array.SetValue(Convert.ChangeType(temp[i], property.PropertyType.GetElementType()), i);
}
for (int i = 0; i < array.Length; i++)
{
array.SetValue(Convert.ChangeType(temp[i], property.PropertyType.GetElementType()), i);
}

property.SetValue(r, array, null);
property.SetValue(r, array, null);
}
}
}
else
Expand Down

0 comments on commit 1e9f379

Please sign in to comment.