forked from codecadwallader/codemaid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeModel.cs
More file actions
97 lines (82 loc) · 2.64 KB
/
CodeModel.cs
File metadata and controls
97 lines (82 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using EnvDTE;
using SteveCadwallader.CodeMaid.Helpers;
using SteveCadwallader.CodeMaid.Model.CodeItems;
using System.Threading;
namespace SteveCadwallader.CodeMaid.Model
{
/// <summary>
/// This class encapsulates the representation of a document, including its code items and
/// current state.
/// </summary>
internal class CodeModel
{
#region Fields
private bool _isBuilding;
private bool _isStale;
#endregion Fields
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CodeModel" /> class.
/// </summary>
/// <param name="document">The document.</param>
internal CodeModel(Document document)
{
CodeItems = new SetCodeItems();
Document = document;
IsBuiltWaitHandle = new ManualResetEvent(false);
}
#endregion Constructors
#region Properties
/// <summary>
/// Gets the document.
/// </summary>
internal Document Document { get; }
/// <summary>
/// Gets or sets the code items.
/// </summary>
internal SetCodeItems CodeItems { get; set; }
/// <summary>
/// Gets or sets a flag indicating if this model is currently being built.
/// </summary>
internal bool IsBuilding
{
get { return _isBuilding; }
set
{
if (_isBuilding != value)
{
OutputWindowHelper.DiagnosticWriteLine($"CodeModel.IsBuilding changing to '{value}' for '{Document.FullName}'");
_isBuilding = value;
if (_isBuilding)
{
IsBuiltWaitHandle.Reset();
}
else
{
IsBuiltWaitHandle.Set();
}
}
}
}
/// <summary>
/// Gets a wait handle that will be signaled when building is complete.
/// </summary>
internal ManualResetEvent IsBuiltWaitHandle { get; }
/// <summary>
/// Gets or sets a flag indicating if this model is stale.
/// </summary>
internal bool IsStale
{
get { return _isStale; }
set
{
if (_isStale != value)
{
OutputWindowHelper.DiagnosticWriteLine($"CodeModel.IsStale changing to '{value}' for '{Document.FullName}'");
_isStale = value;
}
}
}
#endregion Properties
}
}