add.brief.option.add.gnome.vfs.binary.helper
[tfs.git] / class / Microsoft.TeamFoundation.VersionControl.Client / ChangeRequest.cs
blob5c3ac80acd95f84aca6bc92b49cfe00d9f69e3f9
1 //
2 // Microsoft.TeamFoundation.VersionControl.Client.ChangeRequest
3 //
4 // Authors:
5 // Joel Reed (joelwreed@gmail.com)
6 //
7 // Copyright (C) 2007 Joel Reed
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;
32 using Microsoft.TeamFoundation.VersionControl.Common;
34 namespace Microsoft.TeamFoundation.VersionControl.Client
36 internal class ChangeRequest
38 private RequestType requestType = RequestType.None;
39 private int deletionId = 0;
40 private int encoding = 65001; // used to be -2
41 private ItemType itemType = ItemType.Any;
42 private LockLevel @lockLevel = LockLevel.None;
43 private string target;
44 private ItemType targetType = ItemType.Any;
45 private ItemSpec item;
46 private VersionSpec versionSpec = VersionSpec.Latest;
48 public ChangeRequest(string path, RequestType requestType, ItemType itemType)
50 this.item = new ItemSpec(path, RecursionType.None);
51 this.requestType = requestType;
52 this.itemType = itemType;
55 public ChangeRequest(string path, RequestType requestType, ItemType itemType,
56 RecursionType recursion, LockLevel lockLevel)
58 this.item = new ItemSpec(path, recursion);
59 this.requestType = requestType;
60 this.itemType = itemType;
61 this.lockLevel = lockLevel;
64 public ChangeRequest(string path, string target, RequestType requestType, ItemType itemType)
66 this.item = new ItemSpec(path, RecursionType.None);
67 this.target = target;
68 this.requestType = requestType;
69 this.itemType = itemType;
72 public LockLevel LockLevel
74 get { return lockLevel; }
77 public ItemSpec Item
79 get { return item; }
82 public VersionSpec VersionSpec
84 get { return versionSpec; }
87 public ItemType ItemType
89 get { return itemType; }
90 set { itemType = value; }
93 public ItemType TargetType
95 get { return targetType; }
96 set { targetType = value; }
99 public RequestType RequestType
101 get { return requestType; }
102 set { requestType = value; }
105 public int DeletionId
107 get { return deletionId; }
108 set { deletionId = value; }
111 public int Encoding
113 get { return encoding; }
114 set { encoding = value; }
117 public string Target
119 get { return target; }
120 set { target = value; }
123 internal void ToXml(XmlWriter writer, string element)
125 writer.WriteStartElement("ChangeRequest");
126 writer.WriteAttributeString("req", RequestType.ToString());
128 if (RequestType == RequestType.Lock || LockLevel != LockLevel.None)
129 writer.WriteAttributeString("lock", LockLevel.ToString());
131 if (RequestType == RequestType.Add)
132 writer.WriteAttributeString("enc", Encoding.ToString());
134 writer.WriteAttributeString("type", ItemType.ToString());
135 //writer.WriteAttributeString("did", DeletionId.ToString());
136 //writer.WriteAttributeString("targettype", TargetType.ToString());
138 if (!String.IsNullOrEmpty(Target))
140 // convert local path specs from platform paths to tfs paths as needed
141 string fxdTarget;
142 if (VersionControlPath.IsServerItem(Target)) fxdTarget = Target;
143 else fxdTarget = TfsPath.FromPlatformPath(Target);
144 writer.WriteAttributeString("target", fxdTarget);
147 this.Item.ToXml(writer, "item");
148 //this.VersionSpec.ToXml(writer, "vspec");
150 writer.WriteEndElement();