Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JConstructor"/> class from another <see cref="JConstructor"/> object.
 /// </summary>
 /// <param name="other">A <see cref="JConstructor"/> object to copy from.</param>
 public JConstructor(JConstructor other)
     : base(other)
 {
     _name = other.Name;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads an <see cref="JConstructor"/> from a <see cref="JsonReader"/>. 
        /// </summary>
        /// <param name="reader">A <see cref="JsonReader"/> that will be read for the content of the <see cref="JConstructor"/>.</param>
        /// <returns>A <see cref="JConstructor"/> that contains the JSON that was read from the specified <see cref="JsonReader"/>.</returns>
        public static JConstructor Load(JsonReader reader)
        {
            if (reader.TokenType == JsonToken.None)
              {
            if (!reader.Read())
              throw new Exception("Error reading JConstructor from JsonReader.");
              }

              if (reader.TokenType != JsonToken.StartConstructor)
            throw new Exception("Error reading JConstructor from JsonReader. Current JsonReader item is not a constructor: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));

              JConstructor c = new JConstructor((string)reader.Value);
              c.SetLineInfo(reader as IJsonLineInfo);

              if (!reader.Read())
            throw new Exception("Error reading JConstructor from JsonReader.");

              c.ReadContentFrom(reader);

              return c;
        }