public AppendFormat ( string format ) : void | ||
format | string | |
Результат | void |
int MakeStringFromToken(List<Token> tokens, int pos, Dictionary<Reference, string> referencePaths, IndentingStringBuilder sb) { var token = tokens[pos]; TokenType? next = pos + 1 < tokens.Count ? tokens[pos + 1].Tokenkind : new TokenType?(); int skip = 0; switch (token.Tokenkind) { case TokenType.StartScope: case TokenType.StartDict: if (next == TokenType.EndScope || next == TokenType.EndDict) { sb.AppendFormatLine("{{}}{0}", OptionalComma(tokens, pos + 1)); ++skip; } else { sb.AppendFormatLine("{{"); sb.Indent(); } break; case TokenType.EndScope: case TokenType.EndDict: sb.DeIndent(); sb.AppendFormatLine("}}{0}", OptionalComma(tokens, pos)); break; case TokenType.StartList: if (next == TokenType.EndList) { sb.AppendFormatLine("[]{0}", OptionalComma(tokens, pos + 1)); ++skip; } else { sb.AppendFormatLine("["); sb.Indent(); } break; case TokenType.EndList: sb.DeIndent(); sb.AppendFormatLine("]{0}", OptionalComma(tokens, pos)); break; case TokenType.SimpleFieldValue: sb.AppendFormatLine("{0}{1}", MakeFieldValue(token, token.Value), OptionalComma(tokens, pos)); break; case TokenType.SeenBeforeWithReference: sb.AppendFormatLine("{0}{1}", MakeFieldValue(token, referencePaths[token.ReferenceNo]), OptionalComma(tokens, pos)); break; case TokenType.FieldnameWithTypeAndReference: string value = MakeFieldValue(token, ""); sb.AppendFormat("{0}", value); break; default: throw new ArgumentOutOfRangeException(); } return skip; }
int MakeStringFromToken(List <Token> tokens, int pos, Dictionary <Reference, string> referencePaths, IndentingStringBuilder sb) { var token = tokens[pos]; TokenType?next = pos + 1 < tokens.Count ? tokens[pos + 1].Tokenkind : new TokenType?(); int skip = 0; switch (token.Tokenkind) { case TokenType.StartScope: case TokenType.StartDict: if (next == TokenType.EndScope || next == TokenType.EndDict) { sb.AppendFormatLine("{{}}{0}", OptionalComma(tokens, pos + 1)); ++skip; } else { sb.AppendFormatLine("{{"); sb.Indent(); } break; case TokenType.EndScope: case TokenType.EndDict: sb.DeIndent(); sb.AppendFormatLine("}}{0}", OptionalComma(tokens, pos)); break; case TokenType.StartList: if (next == TokenType.EndList) { sb.AppendFormatLine("[]{0}", OptionalComma(tokens, pos + 1)); ++skip; } else { sb.AppendFormatLine("["); sb.Indent(); } break; case TokenType.EndList: sb.DeIndent(); sb.AppendFormatLine("]{0}", OptionalComma(tokens, pos)); break; case TokenType.SimpleFieldValue: sb.AppendFormatLine("{0}{1}", MakeFieldValue(token, token.Value), OptionalComma(tokens, pos)); break; case TokenType.SeenBeforeWithReference: sb.AppendFormatLine("{0}{1}", MakeFieldValue(token, referencePaths[token.ReferenceNo]), OptionalComma(tokens, pos)); break; case TokenType.FieldnameWithTypeAndReference: string value = MakeFieldValue(token, ""); sb.AppendFormat("{0}", value); break; default: throw new ArgumentOutOfRangeException(); } return(skip); }