本文整理汇总了C#中JsonToken.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# JsonToken.ToString方法的具体用法?C# JsonToken.ToString怎么用?C# JsonToken.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonToken
的用法示例。
在下文中一共展示了JsonToken.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AutoComplete
internal void AutoComplete(JsonToken tokenBeingWritten)
{
// gets new state based on the current state and what is being written
State newState = StateArray[(int)tokenBeingWritten][(int)_currentState];
if (newState == State.Error)
throw JsonWriterException.Create(this, "Token {0} in state {1} would result in an invalid JSON object.".FormatWith(CultureInfo.InvariantCulture, tokenBeingWritten.ToString(), _currentState.ToString()), null);
if ((_currentState == State.Object || _currentState == State.Array || _currentState == State.Constructor) && tokenBeingWritten != JsonToken.Comment)
{
WriteValueDelimiter();
}
if (_formatting == Formatting.Indented)
{
if (_currentState == State.Property)
WriteIndentSpace();
// don't indent a property when it is the first token to be written (i.e. at the start)
if ((_currentState == State.Array || _currentState == State.ArrayStart || _currentState == State.Constructor || _currentState == State.ConstructorStart)
|| (tokenBeingWritten == JsonToken.PropertyName && _currentState != State.Start))
WriteIndent();
}
_currentState = newState;
}
示例2: AutoComplete
internal void AutoComplete(JsonToken tokenBeingWritten)
{
if (tokenBeingWritten != JsonToken.StartObject
&& tokenBeingWritten != JsonToken.StartArray
&& tokenBeingWritten != JsonToken.StartConstructor)
UpdateScopeWithFinishedValue();
// gets new state based on the current state and what is being written
State newState = StateArray[(int)tokenBeingWritten][(int)_currentState];
if (newState == State.Error)
{
throw new JsonWriterException("Token {0} in state {1} would result in an invalid JSON object.".FormatWith(CultureInfo.InvariantCulture, tokenBeingWritten.ToString(), _currentState.ToString()));
}
if ((_currentState == State.Object || _currentState == State.Array || _currentState == State.Constructor) && tokenBeingWritten != JsonToken.Comment)
{
WriteValueDelimiter();
}
else if (_currentState == State.Property)
{
if (_formatting == Formatting.Indented)
WriteIndentSpace();
}
if (_formatting == Formatting.Indented)
{
WriteState writeState = WriteState;
// don't indent a property when it is the first token to be written (i.e. at the start)
if ((tokenBeingWritten == JsonToken.PropertyName && writeState != WriteState.Start) ||
writeState == WriteState.Array || writeState == WriteState.Constructor)
{
WriteIndent();
}
}
_currentState = newState;
}
示例3: AutoComplete
private void AutoComplete(JsonToken tokenBeingWritten)
{
int token;
switch (tokenBeingWritten)
{
default:
token = (int)tokenBeingWritten;
break;
case JsonToken.Integer:
case JsonToken.Float:
case JsonToken.String:
case JsonToken.Boolean:
case JsonToken.Null:
case JsonToken.Undefined:
case JsonToken.Date:
// a value is being written
token = 7;
break;
}
// gets new state based on the current state and what is being written
State newState = stateArray[token, (int)_currentState];
if (newState == State.Error)
throw new JsonWriterException("Token {0} in state {1} would result in an invalid JavaScript object.".FormatWith(CultureInfo.InvariantCulture, tokenBeingWritten.ToString(), _currentState.ToString()));
if ((_currentState == State.Object || _currentState == State.Array || _currentState == State.Constructor) && tokenBeingWritten != JsonToken.Comment)
{
WriteValueDelimiter();
}
else if (_currentState == State.Property)
{
if (_formatting == Formatting.Indented)
WriteIndentSpace();
}
// don't indent a property when it is the first token to be written (i.e. at the start)
if ((tokenBeingWritten == JsonToken.PropertyName && WriteState != WriteState.Start) ||
WriteState == WriteState.Array || WriteState == WriteState.Constructor)
{
WriteIndent();
}
_currentState = newState;
}
示例4: AutoComplete
private void AutoComplete(JsonToken tokenBeingWritten)
{
int token;
switch (tokenBeingWritten)
{
default:
token = (int)tokenBeingWritten;
break;
case JsonToken.Integer:
case JsonToken.Float:
case JsonToken.String:
case JsonToken.Boolean:
case JsonToken.Null:
case JsonToken.Undefined:
case JsonToken.Date:
// a value is being written
token = 5;
break;
}
// gets new state based on the current state and what is being written
State newState = stateArray[token, (int)_currentState];
if (newState == State.Error)
throw new JsonWriterException(string.Format("Token {0} in state {1} would result in an invalid JavaScript object.", tokenBeingWritten.ToString(), _currentState.ToString()));
if ((_currentState == State.Object || _currentState == State.Array) && tokenBeingWritten != JsonToken.Comment)
{
_writer.Write(',');
}
else if (_currentState == State.Property)
{
if (_formatting == Formatting.Indented)
_writer.Write(' ');
}
if (tokenBeingWritten == JsonToken.PropertyName ||
(WriteState == WriteState.Array))
{
WriteIndent();
}
_currentState = newState;
}
示例5: readPropertyAsString
private string readPropertyAsString(JsonToken expectedTokenType)
{
// Read away property name
jr.Read();
if (jr.TokenType == expectedTokenType)
{
string value;
if (jr.Value is string)
value = (string)jr.Value;
else if (jr.Value is bool)
value = jr.Value.ToString().ToLower();
else if (jr.Value is decimal)
value = ((decimal)jr.Value).ToString(CultureInfo.InvariantCulture);
else
value = jr.Value.ToString();
jr.Read();
return value;
}
else
{
jr.Read();
throw new FhirFormatException("Expected property of type " + expectedTokenType.ToString());
}
}
示例6: AutoComplete
// Token: 0x06000117 RID: 279
// RVA: 0x0002ABF0 File Offset: 0x00028DF0
internal void AutoComplete(JsonToken tokenBeingWritten)
{
JsonWriter.State state = JsonWriter.StateArray[(int)tokenBeingWritten][(int)this._currentState];
if (state == JsonWriter.State.Error)
{
throw JsonWriterException.Create(this, StringUtils.FormatWith("Token {0} in state {1} would result in an invalid JSON object.", CultureInfo.InvariantCulture, tokenBeingWritten.ToString(), this._currentState.ToString()), null);
}
if ((this._currentState == JsonWriter.State.Object || this._currentState == JsonWriter.State.Array || this._currentState == JsonWriter.State.Constructor) && tokenBeingWritten != JsonToken.Comment)
{
this.WriteValueDelimiter();
}
if (this._formatting == Formatting.Indented)
{
if (this._currentState == JsonWriter.State.Property)
{
this.WriteIndentSpace();
}
if (this._currentState == JsonWriter.State.Array || this._currentState == JsonWriter.State.ArrayStart || this._currentState == JsonWriter.State.Constructor || this._currentState == JsonWriter.State.ConstructorStart || (tokenBeingWritten == JsonToken.PropertyName && this._currentState != JsonWriter.State.Start))
{
this.WriteIndent();
}
}
this._currentState = state;
}