• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# JsonContainerType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中JsonContainerType的典型用法代码示例。如果您正苦于以下问题:C# JsonContainerType类的具体用法?C# JsonContainerType怎么用?C# JsonContainerType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JsonContainerType类属于命名空间,在下文中一共展示了JsonContainerType类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Push

 // Token: 0x06000074 RID: 116
 // RVA: 0x00028D14 File Offset: 0x00026F14
 private void Push(JsonContainerType value)
 {
     this.UpdateScopeWithFinishedValue();
     if (this._currentPosition.Type == JsonContainerType.None)
     {
         this._currentPosition = new JsonPosition(value);
         return;
     }
     this._stack.Add(this._currentPosition);
     this._currentPosition = new JsonPosition(value);
     if (this._maxDepth.HasValue && this.Depth + 1 > this._maxDepth && !this._hasExceededMaxDepth)
     {
         this._hasExceededMaxDepth = true;
         throw JsonReaderException.Create(this, StringUtils.FormatWith("The reader's MaxDepth of {0} has been exceeded.", CultureInfo.InvariantCulture, this._maxDepth));
     }
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:18,代码来源:JsonReader.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# JsonConverter类代码示例发布时间:2022-05-24
下一篇:
C# JsonArray类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap