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


C# JsonToken.ToString方法代码示例

本文整理汇总了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;
        }
开发者ID:jrwren,项目名称:yahoofinance,代码行数:26,代码来源:JsonWriter.cs

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

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

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

示例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());
            }
        }
开发者ID:avontd2868,项目名称:vista-novo-fhir,代码行数:27,代码来源:JsonFhirReader.cs

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


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