Json.NET
Code Coverage Statistics for Source File

Newtonsoft.Json\Linq\JRaw.cs

Symbol Coverage: 100.00% (11 of 11)

Branch Coverage: 100.00% (6 of 6)

Cyclomatic Complexity Avg: 1.50 Max:3

Code Lines: 13


L V Source
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
 1
    public JRaw(JRaw other)
20
 1
      : base(other)
21
    {
22
 1
    }
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
 21
    public JRaw(object rawJson)
29
 21
      : base(rawJson, JTokenType.Raw)
30
    {
31
 21
    }
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
 4
      using (StringWriter sw = new StringWriter(CultureInfo.InvariantCulture))
41
 4
      using (JsonTextWriter jsonWriter = new JsonTextWriter(sw))
42
      {
43
 4
        jsonWriter.WriteToken(reader);
44

  
45
 4
        return new JRaw(sw.ToString());
46
      }
47
 4
    }
48

  
49
    internal override JToken CloneToken()
50
    {
51
 1
      return new JRaw(this);
52
 1
    }
53
  }
54
}