~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/TestObjects/Event.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
28
namespace Newtonsoft.Json.Tests.TestObjects
 
29
{
 
30
  /// <summary>
 
31
  /// What types of events are there? Just sticking to a basic set of four for now.
 
32
  /// </summary>
 
33
  /// <remarks></remarks>
 
34
  public enum EventType
 
35
  {
 
36
    Debug = 0,
 
37
    Info = 1,
 
38
    Warning = 2,
 
39
    Error = 3
 
40
  }
 
41
 
 
42
  public sealed class Event
 
43
  {
 
44
 
 
45
    /// <summary>
 
46
    /// If no current user is specified, returns Nothing (0 from VB)
 
47
    /// </summary>
 
48
    /// <returns></returns>
 
49
    /// <remarks></remarks>
 
50
    private static int GetCurrentUserId()
 
51
    {
 
52
      return 0;
 
53
    }
 
54
 
 
55
    /// <summary>
 
56
    /// Gets either the application path or the current stack trace.
 
57
    /// NOTE: You MUST call this from the top level entry point. Otherwise,
 
58
    /// the stack trace will be buried in Logger itself.
 
59
    /// </summary>
 
60
    /// <returns></returns>
 
61
    /// <remarks></remarks>
 
62
    private static string GetCurrentSubLocation()
 
63
    {
 
64
      return "";
 
65
    }
 
66
 
 
67
    private string _sublocation;
 
68
    private int _userId;
 
69
    private EventType _type;
 
70
    private string _summary;
 
71
    private string _details;
 
72
    private string _stackTrace;
 
73
    private string _tag;
 
74
    private DateTime _time;
 
75
 
 
76
    public Event(string summary)
 
77
    {
 
78
      _summary = summary;
 
79
      _time = DateTime.Now;
 
80
 
 
81
      if (_userId == 0) _userId = GetCurrentUserId();
 
82
      //This call only works at top level for now.
 
83
      //If _stackTrace = Nothing Then _stackTrace = Environment.StackTrace
 
84
      if (_sublocation == null) _sublocation = GetCurrentSubLocation();
 
85
    }
 
86
 
 
87
    public Event(string sublocation, int userId, EventType type, string summary, string details, string stackTrace, string tag)
 
88
    {
 
89
      _sublocation = sublocation;
 
90
      _userId = userId;
 
91
      _type = type;
 
92
      _summary = summary;
 
93
      _details = details;
 
94
      _stackTrace = stackTrace;
 
95
      _tag = tag;
 
96
      _time = DateTime.Now;
 
97
 
 
98
      if (_userId == 0) _userId = GetCurrentUserId();
 
99
      //If _stackTrace = Nothing Then _stackTrace = Environment.StackTrace
 
100
      if (_sublocation == null) _sublocation = GetCurrentSubLocation();
 
101
    }
 
102
 
 
103
    public override string ToString()
 
104
    {
 
105
      return string.Format("{{ sublocation = {0}, userId = {1}, type = {2}, summary = {3}, details = {4}, stackTrace = {5}, tag = {6} }}", _sublocation, _userId, _type, _summary, _details, _stackTrace, _tag);
 
106
    }
 
107
 
 
108
    public string sublocation
 
109
    {
 
110
      get { return _sublocation; }
 
111
      set { _sublocation = value; }
 
112
    }
 
113
    public int userId
 
114
    {
 
115
      get { return _userId; }
 
116
      set { _userId = value; }
 
117
    }
 
118
    public EventType type
 
119
    {
 
120
      get { return _type; }
 
121
      set { _type = value; }
 
122
    }
 
123
    public string summary
 
124
    {
 
125
      get { return _summary; }
 
126
      set { _summary = value; }
 
127
    }
 
128
    public string details
 
129
    {
 
130
      get { return _details; }
 
131
      set { _details = value; }
 
132
    }
 
133
    public string stackTrace
 
134
    {
 
135
      get { return _stackTrace; }
 
136
      set { _stackTrace = value; }
 
137
    }
 
138
    public string tag
 
139
    {
 
140
      get { return _tag; }
 
141
      set { _tag = value; }
 
142
    }
 
143
    public DateTime time
 
144
    {
 
145
      get { return _time; }
 
146
    }
 
147
  }
 
148
}
 
 
b'\\ No newline at end of file'