-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathHansoftItem.cs
More file actions
161 lines (143 loc) · 4.18 KB
/
HansoftItem.cs
File metadata and controls
161 lines (143 loc) · 4.18 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HPMSdk;
namespace Hansoft.ObjectWrapper
{
/// <summary>
/// Base class for all items in Hansoft that has a Unique ID.
/// </summary>
public abstract class HansoftItem
{
HPMUniqueID uniqueID;
internal HansoftItem(HPMUniqueID uniqueID)
{
this.uniqueID = uniqueID;
}
/// <summary>
/// Returns the Unique ID for the item. For Task subclasses this will return the task reference in the applicable view (Backlog, Schedule or Bugs).
/// </summary>
public HPMUniqueID UniqueID
{
get
{
return uniqueID;
}
}
/// <summary>
/// The unique id as an integer.
/// </summary>
public int Id
{
get
{
return uniqueID.m_ID;
}
}
/// <summary>
/// The name of the type of this instance
/// </summary>
public string TypeName
{
get
{
return this.GetType().Name;
}
}
/// <summary>
/// The currently connected (through the SessionManager) SDK Session
/// </summary>
static internal HPMSdkSession SdkSession
{
get { return SessionManager.Session; }
}
/// <summary>
/// The currently connected (through the SessionManager) SDK Session
/// </summary>
internal HPMSdkSession Session
{
get { return HansoftItem.SdkSession; }
}
/// <summary>
/// Override of object.Equals that compares the Hansoft Unique ID of items.
/// </summary>
/// <param name="obj">The object to compare with.</param>
/// <returns></returns>
public override bool Equals(object obj)
{
HansoftItem other = obj as HansoftItem;
if (obj != null)
return uniqueID.m_ID == other.uniqueID.m_ID;
else
return base.Equals(obj);
}
/// <summary>
/// Override of object.Hashcode to make sure that objects with the same Unique ID
/// returns the same Hashcode.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return UniqueID.m_ID;
}
/// <summary>
/// The item that this item is arranged under in the particular view/hierarchy.
/// </summary>
public abstract HansoftItem Parent
{
get;
}
/// <summary>
/// The full chain of parents to the top of the view.
/// </summary>
public abstract List<HansoftItem> AllParents
{
get;
}
/// <summary>
/// Indicated whether this item has children.
/// </summary>
public abstract bool HasChildren
{
get;
}
/// <summary>
/// The direct children of this item.
/// </summary>
public abstract List<HansoftItem> Children
{
get;
}
/// <summary>
/// The direct and recursive children of this item.
/// </summary>
public abstract List<HansoftItem> DeepChildren
{
get;
}
/// <summary>
/// The direct children of this itme that also are leaf items, i.e., they don't have any children in their turn.
/// </summary>
public List<HansoftItem> Leaves
{
get { return Children.FindAll(item => !item.HasChildren); }
}
/// <summary>
/// The direct and recursive children of this item that also are leaf items, i.e., they don't have any children in their turn.
/// </summary>
public List<HansoftItem> DeepLeaves
{
get { return DeepChildren.FindAll(item => !item.HasChildren); }
}
/// <summary>
/// The name of the item
/// </summary>
public abstract string Name
{
get;
set;
}
}
}