Skip to content

Commit

Permalink
parse enums from string
Browse files Browse the repository at this point in the history
  • Loading branch information
boscohyun committed Sep 25, 2024
1 parent eeb89dd commit 33243a2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SkillSerializer : ClassSerializerBase<Skill>
Power = doc["Power"].ToLong(),
Chance = doc["Chance"].AsInt32,
StatPowerRatio = doc["StatPowerRatio"].AsInt32,
ReferencedStatType = (Nekoyume.Model.Stat.StatType)doc["ReferencedStatType"].AsInt32,
ReferencedStatType = Enum.Parse<Nekoyume.Model.Stat.StatType>(doc["ReferencedStatType"].AsString),
};

public override Skill Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class DecimalStatSerializer : ClassSerializerBase<DecimalStat>

public static DecimalStat Deserialize(BsonDocument doc) => new()
{
StatType = (Nekoyume.Model.Stat.StatType)doc["StatType"].AsInt32,
StatType = Enum.Parse<Nekoyume.Model.Stat.StatType>(doc["StatType"].AsString),
BaseValue = doc["BaseValue"].AsDecimal,
AdditionalValue = doc["AdditionalValue"].AsDecimal,
};
Expand Down

0 comments on commit 33243a2

Please sign in to comment.