本文整理汇总了C#中JsonContainerType类的典型用法代码示例。如果您正苦于以下问题:C# JsonContainerType类的具体用法?C# JsonContainerType怎么用?C# JsonContainerType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonContainerType类属于命名空间,在下文中一共展示了JsonContainerType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JsonPosition
public JsonPosition(JsonContainerType type)
{
Type = type;
HasIndex = TypeHasIndex(type);
Position = -1;
PropertyName = null;
}
示例2: AutoCompleteClose
private void AutoCompleteClose(JsonContainerType type)
{
// write closing symbol and calculate new state
int levelsToComplete = 0;
if (_currentPosition.Type == type)
{
levelsToComplete = 1;
}
else
{
int top = Top - 2;
for (int i = top; i >= 0; i--)
{
int currentLevel = top - i;
if (_stack[currentLevel].Type == type)
{
levelsToComplete = i + 2;
break;
}
}
}
if (levelsToComplete == 0)
throw JsonWriterException.Create(this, "No token to close.", null);
for (int i = 0; i < levelsToComplete; i++)
{
JsonToken token = GetCloseTokenForType(Pop());
if (_currentState == State.Property)
WriteNull();
if (_formatting == Formatting.Indented)
{
if (_currentState != State.ObjectStart && _currentState != State.ArrayStart)
WriteIndent();
}
WriteEnd(token);
JsonContainerType currentLevelType = Peek();
switch (currentLevelType)
{
case JsonContainerType.Object:
_currentState = State.Object;
break;
case JsonContainerType.Array:
_currentState = State.Array;
break;
case JsonContainerType.Constructor:
_currentState = State.Array;
break;
case JsonContainerType.None:
_currentState = State.Start;
break;
default:
throw JsonWriterException.Create(this, "Unknown JsonType: " + currentLevelType, null);
}
}
}
示例3: GetCloseTokenForType
private JsonToken GetCloseTokenForType(JsonContainerType type)
{
switch (type)
{
case JsonContainerType.Object:
return JsonToken.EndObject;
case JsonContainerType.Array:
return JsonToken.EndArray;
case JsonContainerType.Constructor:
return JsonToken.EndConstructor;
default:
throw JsonWriterException.Create(this, "No close token for type: " + type, null);
}
}
示例4: WriteEnd
private void WriteEnd(JsonContainerType type)
{
switch (type)
{
case JsonContainerType.Object:
WriteEndObject();
break;
case JsonContainerType.Array:
WriteEndArray();
break;
case JsonContainerType.Constructor:
WriteEndConstructor();
break;
default:
throw JsonWriterException.Create(this, "Unexpected type when writing end: " + type, null);
}
}
示例5: Push
private void Push(JsonContainerType value)
{
if (_currentPosition.Type != JsonContainerType.None)
_stack.Add(_currentPosition);
_currentPosition = new JsonPosition(value);
}
示例6: InternalWriteStart
internal void InternalWriteStart(JsonToken token, JsonContainerType container)
{
UpdateScopeWithFinishedValue();
AutoComplete(token);
Push(container);
}
示例7: InternalWriteEnd
internal void InternalWriteEnd(JsonContainerType container)
{
AutoCompleteClose(container);
}
示例8: TypeHasIndex
internal static bool TypeHasIndex(JsonContainerType type)
{
return (type == JsonContainerType.Array || type == JsonContainerType.Constructor);
}
示例9: Push
private void Push(JsonContainerType value)
{
UpdateScopeWithFinishedValue();
if (_currentPosition.Type == JsonContainerType.None)
{
_currentPosition = new JsonPosition(value);
}
else
{
_stack.Add(_currentPosition);
_currentPosition = new JsonPosition(value);
// this is a little hacky because Depth increases when first property/value is written but only testing here is faster/simpler
if (_maxDepth != null && Depth + 1 > _maxDepth && !_hasExceededMaxDepth)
{
_hasExceededMaxDepth = true;
throw JsonReaderException.Create(this, "The reader's MaxDepth of {0} has been exceeded.".FormatWith(CultureInfo.InvariantCulture, _maxDepth));
}
}
}
示例10: Push
private void Push(JsonContainerType value)
{
if (_currentPosition.Type == JsonContainerType.None)
{
_currentPosition.Type = value;
}
else
{
_stack.Add(_currentPosition);
var state = new JsonPosition
{
Type = value
};
_currentPosition = state;
}
}
示例11: Push
private void Push(JsonContainerType value)
{
UpdateScopeWithFinishedValue();
if (_currentPosition.Type == JsonContainerType.None)
{
_currentPosition.Type = value;
}
else
{
_stack.Add(_currentPosition);
var state = new JsonPosition
{
Type = value
};
_currentPosition = state;
}
}
示例12: AutoCompleteClose
private void AutoCompleteClose(JsonContainerType type)
{
int num1 = 0;
if (this._currentPosition.Type == type)
{
num1 = 1;
}
else
{
int num2 = this.Top - 2;
for (int index = num2; index >= 0; --index)
{
if (this._stack[num2 - index].Type == type)
{
num1 = index + 2;
break;
}
}
}
if (num1 == 0)
throw JsonWriterException.Create(this, "No token to close.", (Exception) null);
for (int index = 0; index < num1; ++index)
{
JsonToken closeTokenForType = this.GetCloseTokenForType(this.Pop());
if (this._currentState == JsonWriter.State.Property)
this.WriteNull();
if (this._formatting == Formatting.Indented && this._currentState != JsonWriter.State.ObjectStart && this._currentState != JsonWriter.State.ArrayStart)
this.WriteIndent();
this.WriteEnd(closeTokenForType);
JsonContainerType jsonContainerType = this.Peek();
switch (jsonContainerType)
{
case JsonContainerType.None:
this._currentState = JsonWriter.State.Start;
break;
case JsonContainerType.Object:
this._currentState = JsonWriter.State.Object;
break;
case JsonContainerType.Array:
this._currentState = JsonWriter.State.Array;
break;
case JsonContainerType.Constructor:
this._currentState = JsonWriter.State.Array;
break;
default:
throw JsonWriterException.Create(this, "Unknown JsonType: " + (object) jsonContainerType, (Exception) null);
}
}
}
示例13: Push
private void Push(JsonContainerType value)
{
if (this._currentPosition.Type == JsonContainerType.None)
{
this._currentPosition.Type = value;
}
else
{
this._stack.Add(this._currentPosition);
this._currentPosition = new JsonPosition()
{
Type = value
};
}
}
示例14: Push
private void Push(JsonContainerType value)
{
if (_currentPosition.Type != JsonContainerType.None)
{
if (_stack == null)
{
_stack = new List<JsonPosition>();
}
_stack.Add(_currentPosition);
}
_currentPosition = new JsonPosition(value);
}
示例15: Push
private void Push(JsonContainerType value)
{
this.UpdateScopeWithFinishedValue();
if (this._currentPosition.Type == JsonContainerType.None)
{
this._currentPosition.Type = value;
}
else
{
this._stack.Add(this._currentPosition);
this._currentPosition = new JsonPosition()
{
Type = value
};
if (!this._maxDepth.HasValue)
return;
int num = this.Depth + 1;
int? nullable = this._maxDepth;
if ((num <= nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) == 0 || this._hasExceededMaxDepth)
return;
this._hasExceededMaxDepth = true;
throw JsonReaderException.Create(this, StringUtils.FormatWith("The reader's MaxDepth of {0} has been exceeded.", (IFormatProvider) CultureInfo.InvariantCulture, (object) this._maxDepth));
}
}