All files
[pithos-ms-client] / trunk / Libraries / Json40r2 / Source / Src / Newtonsoft.Json / Linq / JRaw.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Globalization;
4 using System.IO;
5 using System.Linq;
6 using System.Text;
7
8 namespace Newtonsoft.Json.Linq
9 {
10   /// <summary>
11   /// Represents a raw JSON string.
12   /// </summary>
13   public class JRaw : JValue
14   {
15     /// <summary>
16     /// Initializes a new instance of the <see cref="JRaw"/> class from another <see cref="JRaw"/> object.
17     /// </summary>
18     /// <param name="other">A <see cref="JRaw"/> object to copy from.</param>
19     public JRaw(JRaw other)
20       : base(other)
21     {
22     }
23
24     /// <summary>
25     /// Initializes a new instance of the <see cref="JRaw"/> class.
26     /// </summary>
27     /// <param name="rawJson">The raw json.</param>
28     public JRaw(object rawJson)
29       : base(rawJson, JTokenType.Raw)
30     {
31     }
32
33     /// <summary>
34     /// Creates an instance of <see cref="JRaw"/> with the content of the reader's current token.
35     /// </summary>
36     /// <param name="reader">The reader.</param>
37     /// <returns>An instance of <see cref="JRaw"/> with the content of the reader's current token.</returns>
38     public static JRaw Create(JsonReader reader)
39     {
40       using (StringWriter sw = new StringWriter(CultureInfo.InvariantCulture))
41       using (JsonTextWriter jsonWriter = new JsonTextWriter(sw))
42       {
43         jsonWriter.WriteToken(reader);
44
45         return new JRaw(sw.ToString());
46       }
47     }
48
49     internal override JToken CloneToken()
50     {
51       return new JRaw(this);
52     }
53   }
54 }