2 // Microsoft.TeamFoundation.VersionControl.Client.WorkingFolder
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.
33 using Microsoft
.TeamFoundation
.VersionControl
.Common
;
35 namespace Microsoft
.TeamFoundation
.VersionControl
.Client
37 [System
.Xml
.Serialization
.XmlTypeAttribute(Namespace
="http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/ClientServices/03")]
38 public sealed class WorkingFolder
40 private bool isCloaked
;
41 private string localItem
;
42 private string serverItem
;
43 private WorkingFolderType type
= WorkingFolderType
.Map
;
45 public WorkingFolder(string serverItem
, string localItem
)
47 CheckServerPathStartsWithDollarSlash(serverItem
);
48 this.serverItem
= serverItem
;
49 this.localItem
= Path
.GetFullPath(localItem
);
52 internal static WorkingFolder
FromXml(Repository repository
, XmlReader reader
)
54 string local
= TfsPath
.ToPlatformPath(reader
.GetAttribute("local"));
55 string serverItem
= reader
.GetAttribute("item");
56 return new WorkingFolder(serverItem
, local
);
59 internal void ToXml(XmlWriter writer
, string element
)
61 writer
.WriteStartElement("WorkingFolder");
62 writer
.WriteAttributeString("local", TfsPath
.FromPlatformPath(LocalItem
));
63 writer
.WriteAttributeString("item", ServerItem
);
64 // writer.WriteAttributeString("type", Type.ToString());
65 writer
.WriteEndElement();
68 public override string ToString()
70 StringBuilder sb
= new StringBuilder();
72 sb
.Append("WorkingFolder instance ");
73 sb
.Append(GetHashCode());
75 sb
.Append("\n LocalItem: ");
78 sb
.Append("\n ServerItem: ");
79 sb
.Append(ServerItem
);
84 internal void CheckServerPathStartsWithDollarSlash(string serverItem
)
86 if (VersionControlPath
.IsServerItem(serverItem
)) return;
87 string msg
= String
.Format("TF10125: The path '{0}' must start with {1}", serverItem
, VersionControlPath
.RootFolder
);
88 throw new InvalidPathException(msg
);
93 get { return isCloaked; }
96 public string LocalItem
98 get { return localItem; }
101 public WorkingFolderType Type
106 public string ServerItem
108 get { return serverItem; }