private static TomlValue ParseTomlValue(ITomlRoot root, TokenBuffer tokens) { if (tokens.TryExpect(TokenType.Integer)) { return(ParseTomlInt(root, tokens)); } else if (tokens.TryExpect(TokenType.Float)) { return(ParseTomlFloat(root, tokens)); } else if (tokens.TryExpect(TokenType.DateTime)) { return(TomlDateTime.Parse(root, tokens.Consume().value)); } else if (tokens.TryExpect(TokenType.Timespan)) { return(new TomlTimeSpan(root, TimeSpan.Parse(tokens.Consume().value, CultureInfo.InvariantCulture))); } else if (tokens.TryExpect(TokenType.String)) { return(ParseStringValue(root, tokens)); } else if (tokens.TryExpect(TokenType.LiteralString)) { return(ParseLiteralString(root, tokens)); } else if (tokens.TryExpect(TokenType.MultilineString)) { return(ParseMultilineString(root, tokens)); } else if (tokens.TryExpect(TokenType.MultilineLiteralString)) { return(ParseMultilineLiteralString(root, tokens)); } else if (tokens.TryExpect(TokenType.Bool)) { return(new TomlBool(root, bool.Parse(tokens.Consume().value))); } else if (tokens.TryExpect(TokenType.LBrac)) { return(ParseTomlArray(root, tokens)); } return(null); }
public void Visit(TomlDateTime dt) => data[currentPath] = dt.Value.ToString(CultureInfo.InvariantCulture);
void ITomlObjectVisitor.Visit(TomlDateTime dt) => sb.Append("{").Append("\"type\":\"datetime\", \"value\":\"").Append(XmlConvert.ToString(dt.Value.UtcDateTime, XmlDateTimeSerializationMode.Utc)).Append("\"}");
void ITomlObjectVisitor.Visit(TomlDateTime dt) => this.table[this.currentKey] = dt.Value;
public void Visit(TomlDateTime dt) => this.Item = dt.Value;
private static TomlValue ParseTomlValue(ITomlRoot root, TokenBuffer tokens) { if (tokens.TryExpect(TokenType.Integer)) { return(ParseTomlInt(root, tokens, long.TryParse)); } else if (tokens.TryExpect(TokenType.HexInteger)) { return(ParseTomlInt(root, tokens, TryParseHexInt)); } else if (tokens.TryExpect(TokenType.OctalInteger)) { return(ParseTomlInt(root, tokens, TryParseOctInt)); } else if (tokens.TryExpect(TokenType.BinaryInteger)) { return(ParseTomlInt(root, tokens, TryParseBinInt)); } else if (tokens.TryExpect(TokenType.Float)) { return(ParseTomlFloat(root, tokens)); } else if (tokens.TryExpect(TokenType.DateTime)) { return(TomlDateTime.Parse(root, tokens.Consume().value)); } else if (tokens.TryExpect(TokenType.LocalTime)) { return(ParseLocalDateTime(root, tokens.Consume().value)); } else if (tokens.TryExpect(TokenType.Duration)) { return(TomlDuration.Parse(root, tokens.Consume().value)); } else if (tokens.TryExpect(TokenType.String)) { return(ParseStringValue(root, tokens)); } else if (tokens.TryExpect(TokenType.LiteralString)) { return(ParseLiteralString(root, tokens)); } else if (tokens.TryExpect(TokenType.MultilineString)) { return(ParseMultilineString(root, tokens)); } else if (tokens.TryExpect(TokenType.MultilineLiteralString)) { return(ParseMultilineLiteralString(root, tokens)); } else if (tokens.TryExpect(TokenType.Bool)) { return(new TomlBool(root, bool.Parse(tokens.Consume().value))); } else if (tokens.TryExpect(TokenType.LBrac)) { return(ParseTomlArray(root, tokens)); } return(null); }