Json.NET
Code Coverage Statistics for Source File

Newtonsoft.Json\JsonContainerAttribute.cs

Symbol Coverage: 44.44% (4 of 9)

Branch Coverage: 66.67% (8 of 12)

Cyclomatic Complexity Avg: 1.10 Max:2

Code Lines: 7


L V Source
1
#region License
2
// Copyright (c) 2007 James Newton-King
3
//
4
// Permission is hereby granted, free of charge, to any person
5
// obtaining a copy of this software and associated documentation
6
// files (the "Software"), to deal in the Software without
7
// restriction, including without limitation the rights to use,
8
// copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the
10
// Software is furnished to do so, subject to the following
11
// conditions:
12
//
13
// The above copyright notice and this permission notice shall be
14
// included in all copies or substantial portions of the Software.
15
//
16
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
// OTHER DEALINGS IN THE SOFTWARE.
24
#endregion
25

  
26
using System;
27
using System.Collections.Generic;
28
using System.Linq;
29
using System.Text;
30

  
31
namespace Newtonsoft.Json
32
{
33
  /// <summary>
34
  /// Instructs the <see cref="JsonSerializer"/> how to serialize the object.
35
  /// </summary>
36
  [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)]
37
  public abstract class JsonContainerAttribute : Attribute
38
  {
39
    /// <summary>
40
    /// Gets or sets the id.
41
    /// </summary>
42
    /// <value>The id.</value>
43
    public string Id { get; set; }
44
    /// <summary>
45
    /// Gets or sets the title.
46
    /// </summary>
47
    /// <value>The title.</value>
48
    public string Title { get; set; }
49
    /// <summary>
50
    /// Gets or sets the description.
51
    /// </summary>
52
    /// <value>The description.</value>
53
    public string Description { get; set; }
54

  
55
    // yuck. can't set nullable properties on an attribute in C#
56
    // have to use this approach to get an unset default state
57
    internal bool? _isReference;
58

  
59
    /// <summary>
60
    /// Gets or sets a value that indicates whether to preserve object reference data.
61
    /// </summary>
62
    /// <value>
63
    /// 	<c>true</c> to keep object reference; otherwise, <c>false</c>. The default is <c>false</c>.
64
    /// </value>
65
    public bool IsReference
66
    {
67
 0
      get { return _isReference ?? default(bool); }
68
 3
      set { _isReference = value; }
69
    }
70

  
71
    /// <summary>
72
    /// Initializes a new instance of the <see cref="JsonContainerAttribute"/> class.
73
    /// </summary>
74
 35
    protected JsonContainerAttribute()
75
    {
76
 35
    }
77

  
78
    /// <summary>
79
    /// Initializes a new instance of the <see cref="JsonContainerAttribute"/> class with the specified container Id.
80
    /// </summary>
81
    /// <param name="id">The container Id.</param>
82
 0
    protected JsonContainerAttribute(string id)
83
    {
84
 0
      Id = id;
85
 0
    }
86
  }
87
}