当前位置: 首页>>代码示例>>C#>>正文


C# JsonContainerType类代码示例

本文整理汇总了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;
 }
开发者ID:925coder,项目名称:Newtonsoft.Json,代码行数:7,代码来源:JsonPosition.cs

示例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);
                }
            }
        }
开发者ID:jrwren,项目名称:yahoofinance,代码行数:63,代码来源:JsonWriter.cs

示例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);
     }
 }
开发者ID:jrwren,项目名称:yahoofinance,代码行数:14,代码来源:JsonWriter.cs

示例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);
     }
 }
开发者ID:jrwren,项目名称:yahoofinance,代码行数:17,代码来源:JsonWriter.cs

示例5: Push

        private void Push(JsonContainerType value)
        {
            if (_currentPosition.Type != JsonContainerType.None)
                _stack.Add(_currentPosition);

            _currentPosition = new JsonPosition(value);
        }
开发者ID:jrwren,项目名称:yahoofinance,代码行数:7,代码来源:JsonWriter.cs

示例6: InternalWriteStart

 internal void InternalWriteStart(JsonToken token, JsonContainerType container)
 {
     UpdateScopeWithFinishedValue();
     AutoComplete(token);
     Push(container);
 }
开发者ID:jrwren,项目名称:yahoofinance,代码行数:6,代码来源:JsonWriter.cs

示例7: InternalWriteEnd

 internal void InternalWriteEnd(JsonContainerType container)
 {
     AutoCompleteClose(container);
 }
开发者ID:jrwren,项目名称:yahoofinance,代码行数:4,代码来源:JsonWriter.cs

示例8: TypeHasIndex

 internal static bool TypeHasIndex(JsonContainerType type)
 {
     return (type == JsonContainerType.Array || type == JsonContainerType.Constructor);
 }
开发者ID:925coder,项目名称:Newtonsoft.Json,代码行数:4,代码来源:JsonPosition.cs

示例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));
                }
            }
        }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:21,代码来源:JsonReader.cs

示例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;
   }
 }
开发者ID:jmhdz,项目名称:GalleryServer,代码行数:16,代码来源:JsonWriter.cs

示例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;
      }
    }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:18,代码来源:JsonWriter.cs

示例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);
     }
   }
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:49,代码来源:JsonWriter.cs

示例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
     };
   }
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:15,代码来源:JsonWriter.cs

示例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);
        }
开发者ID:cilliemalan,项目名称:Cargo,代码行数:14,代码来源:JsonWriter.cs

示例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));
   }
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:24,代码来源:JsonReader.cs


注:本文中的JsonContainerType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。