2 // Microsoft.TeamFoundation.VersionControl.Client.ExtendedItem
5 // Joel Reed (joelwreed@gmail.com)
7 // Copyright (C) 2007 Joel Reed
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System
.Collections
;
35 using System
.Web
.Services
;
37 namespace Microsoft
.TeamFoundation
.VersionControl
.Client
39 public sealed class ExtendedItem
41 private ChangeType changeType
= ChangeType
.None
;
42 private int deletionId
;
45 private string localItem
;
46 private string sourceServerItem
;
47 private string targetServerItem
;
48 private string lockOwner
;
49 private bool hasOtherPendingChange
;
50 private ItemType itemType
;
51 private LockLevel lockStatus
;
52 private int versionLatest
;
53 private int versionLocal
;
55 //<ExtendedItem lver="int" did="int" latest="int"
56 //type="Any or Folder or File" enc="int" itemid="int"
57 //local="string" titem="string" sitem="string"
58 //chg="None or Add or Edit or Encoding or Rename or Delete or Undelete or Branch or Merge or Lock"
59 //ochg="boolean" lock="None or Checkin or CheckOut or Unchanged"
62 internal static ExtendedItem
FromXml(Repository repository
, XmlReader reader
)
64 ExtendedItem item
= new ExtendedItem();
66 string chg
= reader
.GetAttribute("chg");
67 if (!String
.IsNullOrEmpty(chg
)) item
.changeType
= (ChangeType
) Enum
.Parse(typeof(ChangeType
), chg
, true);
69 string ochg
= reader
.GetAttribute("ochg");
70 if (!String
.IsNullOrEmpty(ochg
)) item
.hasOtherPendingChange
= bool.Parse(ochg
);
72 string xlock
= reader
.GetAttribute("lock");
73 if (!String
.IsNullOrEmpty(xlock
)) item
.lockStatus
= (LockLevel
) Enum
.Parse(typeof(LockLevel
), xlock
, true);
75 item
.lockOwner
= reader
.GetAttribute("lowner");
76 item
.localItem
= TfsPath
.ToPlatformPath(reader
.GetAttribute("local"));
77 item
.targetServerItem
= reader
.GetAttribute("titem");
78 item
.sourceServerItem
= reader
.GetAttribute("sitem");
80 item
.itemType
= (ItemType
) Enum
.Parse(typeof(ItemType
), reader
.GetAttribute("type"), true);
81 item
.itemId
= Convert
.ToInt32(reader
.GetAttribute("itemid"));
82 item
.encoding
= Convert
.ToInt32(reader
.GetAttribute("enc"));
83 item
.versionLocal
= Convert
.ToInt32(reader
.GetAttribute("lver"));
84 item
.versionLatest
= Convert
.ToInt32(reader
.GetAttribute("latest"));
85 item
.deletionId
= Convert
.ToInt32(reader
.GetAttribute("did"));
90 public override string ToString()
92 StringBuilder sb
= new StringBuilder();
94 sb
.Append("ExtendedItem instance ");
95 sb
.Append(GetHashCode());
97 sb
.Append("\n LockOwner: ");
100 sb
.Append("\n HasOtherPendingChange: ");
101 sb
.Append(HasOtherPendingChange
);
103 sb
.Append("\n ChangeType: ");
104 sb
.Append(ChangeType
);
106 sb
.Append("\n LockStatus: ");
107 sb
.Append(LockStatus
.ToString());
109 sb
.Append("\n VersionLocal: ");
110 sb
.Append(VersionLocal
);
112 sb
.Append("\n VersionLatest: ");
113 sb
.Append(VersionLatest
);
115 sb
.Append("\n Encoding: ");
118 sb
.Append("\n LocalItem: ");
119 sb
.Append(LocalItem
);
121 sb
.Append("\n TargetServerItem: ");
122 sb
.Append(TargetServerItem
);
124 sb
.Append("\n SourceServerItem: ");
125 sb
.Append(SourceServerItem
);
127 sb
.Append("\n ItemId: ");
130 sb
.Append("\n ItemType: ");
133 sb
.Append("\n DeletionId: ");
134 sb
.Append(DeletionId
);
136 return sb
.ToString();
139 public int VersionLatest
141 get { return versionLatest; }
144 public int VersionLocal
146 get { return versionLocal; }
149 public LockLevel LockStatus
151 get { return lockStatus; }
154 public ItemType ItemType
156 get { return itemType; }
159 public ChangeType ChangeType
161 get { return changeType; }
164 public int DeletionId
166 get { return deletionId; }
169 public bool HasOtherPendingChange
171 get { return hasOtherPendingChange; }
174 public bool IsInWorkspace
176 get { return (!String.IsNullOrEmpty(LocalItem)); }
181 get { return versionLatest == versionLocal; }
186 get { return itemId; }
191 get { return encoding; }
194 public string LocalItem
196 get { return localItem; }
199 public string LockOwner
201 get { return lockOwner; }
204 public string SourceServerItem
206 get { return sourceServerItem; }
209 public string TargetServerItem
211 get { return targetServerItem; }