Skip to content

Commit

Permalink
More byml serializer adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
KillzXGaming committed Nov 11, 2023
1 parent 7093ba7 commit 199ffdc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
2 changes: 0 additions & 2 deletions Fushigi.Byml/Serializer/BymlProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public class BymlProperty : Attribute
public string Key { get; set; }
public object DefaultValue { get; set; }

public bool Optional = true;

public BymlProperty() { }

public BymlProperty(string key)
Expand Down
12 changes: 2 additions & 10 deletions Fushigi.Byml/Serializer/BymlSerialize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,15 @@ static BymlHashTable SetHashTable(object section)
var value = properties[i].GetValue(section);

if (byamlAttribute != null)
{
//Skip null optional values
if (byamlAttribute.Optional && value == null)
continue;

//If value is null, use a default value
if (value == null)
value = byamlAttribute.DefaultValue;
}
value = byamlAttribute.DefaultValue;

//Set custom keys as property name if used
string name = byamlAttribute != null && byamlAttribute.Key != null ? byamlAttribute.Key : properties[i].Name;

if (value == null)
continue;

var node = SetBymlValue(properties[i].GetValue(section));
var node = SetBymlValue(value);
bymlProperties.AddNode(node.Id, node, name);
}
return bymlProperties;
Expand Down

0 comments on commit 199ffdc

Please sign in to comment.