public static bool TryParse(TextSpan value, out BonusType?type) { if (!value.StartsWith("TYPE=")) { type = null; return(false); } value = value.Substring("TYPE=".Length); var name = value; var dotIdx = name.IndexOf('.'); if (dotIdx >= 0) { name = name.Substring(0, dotIdx); } bool replace = value.EndsWith(".REPLACE"); bool stack = value.EndsWith(".STACK"); type = new BonusType(name.Value, replace, stack); return(true); }