support for tf add /recursive <path>
[tfs.git] / class / Microsoft.TeamFoundation.VersionControl.Client / ChangeRequest.cs
blob6c2e50d6f79accd7d863f269e7ba6935f6ecf89d
1 //
2 // Microsoft.TeamFoundation.VersionControl.Client.ChangeRequest
3 //
4 // Authors:
5 // Joel Reed (joelwreed@gmail.com)
6 //
8 //
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:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
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.
29 using System;
30 using System.IO;
31 using System.Xml;
33 namespace Microsoft.TeamFoundation.VersionControl.Client
35 internal class ChangeRequest
37 private RequestType requestType = RequestType.None;
38 private int deletionId = 0;
39 private int encoding = 65001; // used to be -2
40 private ItemType itemType = ItemType.Any;
41 private LockLevel @lockLevel = LockLevel.None;
42 private string target;
43 private ItemType targetType = ItemType.Any;
44 private ItemSpec item;
45 private VersionSpec versionSpec = VersionSpec.Latest;
47 public ChangeRequest(string path, RequestType requestType, ItemType itemType)
49 this.item = new ItemSpec(path, RecursionType.None);
50 this.requestType = requestType;
51 this.itemType = itemType;
54 public ChangeRequest(string path, string target, RequestType requestType, ItemType itemType)
56 this.item = new ItemSpec(path, RecursionType.None);
57 this.target = target;
58 this.requestType = requestType;
59 this.itemType = itemType;
62 public LockLevel LockLevel
64 get { return lockLevel; }
67 public ItemSpec Item
69 get { return item; }
72 public VersionSpec VersionSpec
74 get { return versionSpec; }
77 public ItemType ItemType
79 get { return itemType; }
80 set { itemType = value; }
83 public ItemType TargetType
85 get { return targetType; }
86 set { targetType = value; }
89 public RequestType RequestType
91 get { return requestType; }
92 set { requestType = value; }
95 public int DeletionId
97 get { return deletionId; }
98 set { deletionId = value; }
101 public int Encoding
103 get { return encoding; }
104 set { encoding = value; }
107 public string Target
109 get { return target; }
110 set { target = value; }
113 internal void ToXml(XmlWriter writer, string element)
115 writer.WriteStartElement("ChangeRequest");
116 writer.WriteAttributeString("req", RequestType.ToString());
117 writer.WriteAttributeString("lock", LockLevel.ToString());
119 if (RequestType == RequestType.Add)
120 writer.WriteAttributeString("enc", Encoding.ToString());
122 writer.WriteAttributeString("type", ItemType.ToString());
123 //writer.WriteAttributeString("did", DeletionId.ToString());
124 //writer.WriteAttributeString("targettype", TargetType.ToString());
126 if (!String.IsNullOrEmpty(Target))
127 writer.WriteAttributeString("target", Target);
129 this.Item.ToXml(writer, "item");
130 //this.VersionSpec.ToXml(writer, "vspec");
132 writer.WriteEndElement();