コード例 #1
0
        /// <summary>
        /// Loads an <see cref="JProperty"/> from a <see cref="JsonReader"/>.
        /// </summary>
        /// <param name="reader">A <see cref="JsonReader"/> that will be read for the content of the <see cref="JProperty"/>.</param>
        /// <returns>A <see cref="JProperty"/> that contains the JSON that was read from the specified <see cref="JsonReader"/>.</returns>
        public static new JProperty Load(JsonReader reader)
        {
            if (reader.TokenType == JsonToken.None)
            {
                if (!reader.Read())
                {
                    throw JsonReaderException.Create(reader, "Error reading JProperty from JsonReader.");
                }
            }

            while (reader.TokenType == JsonToken.Comment)
            {
                reader.Read();
            }

            if (reader.TokenType != JsonToken.PropertyName)
            {
                throw JsonReaderException.Create(reader, "Error reading JProperty from JsonReader. Current JsonReader item is not a property: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
            }

            JProperty p = new JProperty((string)reader.Value);

            p.SetLineInfo(reader as IJsonLineInfo);

            p.ReadTokenFrom(reader);

            return(p);
        }
コード例 #2
0
ファイル: JProperty.cs プロジェクト: Leonardo-YXH/tools
        /// <summary>
        /// Loads an <see cref="JProperty"/> from a <see cref="JsonReader"/>.
        /// </summary>
        /// <param name="reader">A <see cref="JsonReader"/> that will be read for the content of the <see cref="JProperty"/>.</param>
        /// <param name="settings">The <see cref="JsonLoadSettings"/> used to load the JSON.
        /// If this is null, default load settings will be used.</param>
        /// <returns>A <see cref="JProperty"/> that contains the JSON that was read from the specified <see cref="JsonReader"/>.</returns>
        public new static JProperty Load(JsonReader reader, JsonLoadSettings settings)
        {
            if (reader.TokenType == JsonToken.None)
            {
                if (!reader.Read())
                {
                    throw JsonReaderException.Create(reader, "Error reading JProperty from JsonReader.");
                }
            }

            reader.MoveToContent();

            if (reader.TokenType != JsonToken.PropertyName)
            {
                throw JsonReaderException.Create(reader, "Error reading JProperty from JsonReader. Current JsonReader item is not a property: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
            }

            JProperty p = new JProperty((string)reader.Value);

            p.SetLineInfo(reader as IJsonLineInfo, settings);

            p.ReadTokenFrom(reader, settings);

            return(p);
        }
コード例 #3
0
ファイル: JProperty.cs プロジェクト: smdx24/CPI-Source-Code
        public new static JProperty Load(JsonReader reader)
        {
            if (reader.TokenType == JsonToken.None && !reader.Read())
            {
                throw new Exception("Error reading JProperty from JsonReader.");
            }
            if (reader.TokenType != JsonToken.PropertyName)
            {
                throw new Exception("Error reading JProperty from JsonReader. Current JsonReader item is not a property: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
            }
            JProperty jProperty = new JProperty((string)reader.Value);

            jProperty.SetLineInfo(reader as IJsonLineInfo);
            jProperty.ReadTokenFrom(reader);
            return(jProperty);
        }
コード例 #4
0
        public static JProperty Load(JsonReader reader)
        {
            if (reader.TokenType == JsonToken.None && !reader.Read())
            {
                throw JsonReaderException.Create(reader, "Error reading JProperty from JsonReader.");
            }
            while (reader.TokenType == JsonToken.Comment)
            {
                reader.Read();
            }
            if (reader.TokenType != JsonToken.PropertyName)
            {
                throw JsonReaderException.Create(reader, StringUtils.FormatWith("Error reading JProperty from JsonReader. Current JsonReader item is not a property: {0}", (IFormatProvider)CultureInfo.InvariantCulture, (object)reader.TokenType));
            }
            JProperty jproperty = new JProperty((string)reader.Value);

            jproperty.SetLineInfo(reader as IJsonLineInfo);
            jproperty.ReadTokenFrom(reader);
            return(jproperty);
        }
コード例 #5
0
ファイル: JProperty.cs プロジェクト: draptik/RepoSync
    /// <summary>
    /// Loads an <see cref="JProperty"/> from a <see cref="JsonReader"/>. 
    /// </summary>
    /// <param name="reader">A <see cref="JsonReader"/> that will be read for the content of the <see cref="JProperty"/>.</param>
    /// <returns>A <see cref="JProperty"/> that contains the JSON that was read from the specified <see cref="JsonReader"/>.</returns>
    public static new JProperty Load(JsonReader reader)
    {
      if (reader.TokenType == JsonToken.None)
      {
        if (!reader.Read())
          throw JsonReaderException.Create(reader, "Error reading JProperty from JsonReader.");
      }

      while (reader.TokenType == JsonToken.Comment)
      {
        reader.Read();
      }

      if (reader.TokenType != JsonToken.PropertyName)
        throw JsonReaderException.Create(reader, "Error reading JProperty from JsonReader. Current JsonReader item is not a property: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));

      JProperty p = new JProperty((string)reader.Value);
      p.SetLineInfo(reader as IJsonLineInfo);

      p.ReadTokenFrom(reader);

      return p;
    }
コード例 #6
0
ファイル: JProperty.cs プロジェクト: tanis2000/FEZ
 public static JProperty Load(JsonReader reader)
 {
   if (reader.TokenType == JsonToken.None && !reader.Read())
     throw JsonReaderException.Create(reader, "Error reading JProperty from JsonReader.");
   while (reader.TokenType == JsonToken.Comment)
     reader.Read();
   if (reader.TokenType != JsonToken.PropertyName)
     throw JsonReaderException.Create(reader, StringUtils.FormatWith("Error reading JProperty from JsonReader. Current JsonReader item is not a property: {0}", (IFormatProvider) CultureInfo.InvariantCulture, (object) reader.TokenType));
   JProperty jproperty = new JProperty((string) reader.Value);
   jproperty.SetLineInfo(reader as IJsonLineInfo);
   jproperty.ReadTokenFrom(reader);
   return jproperty;
 }