internal static Failure FromXml(Repository repository, XmlReader reader) { Failure failure = new Failure(); string requestType = reader.GetAttribute("req"); if (!String.IsNullOrEmpty(requestType)) { failure.requestType = (RequestType)Enum.Parse(typeof(RequestType), requestType, true); } failure.code = reader.GetAttribute("code"); failure.localItem = TfsPath.ToPlatformPath(reader.GetAttribute("local")); string elementName = reader.Name; while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName) { break; } if (reader.NodeType == XmlNodeType.Element && reader.Name == "Message") { failure.message = reader.ReadString(); } } return(failure); }
// <PendingChange chg="Add Edit Encoding" hash="" uhash="" pcid="-339254" /> internal static PendingChange FromXml(Repository repository, XmlReader reader) { PendingChange change = new PendingChange(); change.versionControlServer = repository.VersionControlServer; change.serverItem = reader.GetAttribute("item"); change.localItem = TfsPath.ToPlatformPath(reader.GetAttribute("local")); change.itemId = Convert.ToInt32(reader.GetAttribute("itemid")); change.encoding = Convert.ToInt32(reader.GetAttribute("enc")); change.creationDate = DateTime.Parse(reader.GetAttribute("date")); string itype = reader.GetAttribute("type"); if (!String.IsNullOrEmpty(itype)) { change.itemType = (ItemType)Enum.Parse(typeof(ItemType), itype, true); } change.downloadUrl = reader.GetAttribute("durl"); string chgAttr = reader.GetAttribute("chg"); change.changeType = (ChangeType)Enum.Parse(typeof(ChangeType), chgAttr.Replace(" ", ","), true); if (change.changeType == ChangeType.Edit) { change.itemType = ItemType.File; } return(change); }
//<s:complexType name="GetOperation"> // <s:sequence> // <s:element minOccurs="0" maxOccurs="1" name="HashValue" type="s:base64Binary"/> // <s:element minOccurs="0" maxOccurs="1" name="Properties" type="tns:ArrayOfPropertyValue"/> // <s:element minOccurs="0" maxOccurs="1" name="PropertyValues" type="tns:ArrayOfPropertyValue"/> // </s:sequence> // <s:attribute default="Any" name="type" type="tns:ItemType"/> // <s:attribute default="0" name="itemid" type="s:int"/> // <s:attribute name="slocal" type="s:string"/> // <s:attribute name="tlocal" type="s:string"/> // <s:attribute name="titem" type="s:string"/> // <s:attribute name="sitem" type="s:string"/> // <s:attribute default="0" name="sver" type="s:int"/> // <s:attribute default="-2" name="vrevto" type="s:int"/> // <s:attribute default="0" name="lver" type="s:int"/> // <s:attribute default="0" name="did" type="s:int"/> // <s:attribute default="0" name="chgEx" type="s:int"/> // <s:attribute default="None" name="chg" type="tns:ChangeType"/> // <s:attribute default="None" name="lock" type="tns:LockLevel"/> // <s:attribute default="true" name="il" type="s:boolean"/> // <s:attribute default="0" name="pcid" type="s:int"/> // <s:attribute default="false" name="cnflct" type="s:boolean"/> // <s:attribute default="None" name="cnflctchg" type="tns:ChangeType"/> // <s:attribute default="0" name="cnflctchgEx" type="s:int"/> // <s:attribute default="0" name="cnflctitemid" type="s:int"/> // <s:attribute name="nmscnflct" type="s:unsignedByte" use="required"/> // <s:attribute name="durl" type="s:string"/> // <s:attribute default="-2" name="enc" type="s:int"/> // <s:attribute default="0001-01-01T00:00:00" name="vsd" type="s:dateTime"/> //</s:complexType> internal static GetOperation FromXml(XElement element) { GetOperation getOperation = new GetOperation { ChangeType = ChangeType.None, ItemType = ItemType.Any, LockLevel = LockLevel.None, VersionServer = 0, VersionLocal = 0, }; getOperation.ItemType = EnumHelper.ParseItemType(element.GetAttribute("type")); getOperation.ItemId = GeneralHelper.XmlAttributeToInt(element.GetAttribute("itemid")); getOperation.SourceLocalItem = TfsPath.ToPlatformPath(element.GetAttribute("slocal")); getOperation.TargetLocalItem = TfsPath.ToPlatformPath(element.GetAttribute("tlocal")); getOperation.SourceServerItem = element.GetAttribute("sitem"); getOperation.TargetServerItem = element.GetAttribute("titem"); getOperation.VersionServer = GeneralHelper.XmlAttributeToInt(element.GetAttribute("sver")); getOperation.VersionLocal = GeneralHelper.XmlAttributeToInt(element.GetAttribute("lver")); getOperation.ChangeType = EnumHelper.ParseChangeType(element.GetAttribute("chg")); // setup download url if found getOperation.ArtifactUri = element.GetAttribute("durl"); // here's what you get if you remap a working folder from one // team project to another team project with the same file // first you get the update getOperation, then you get this later on // <GetOperation type="File" itemid="159025" slocal="foo.xml" titem="$/bar/foo.xml" lver="12002"><HashValue /></GetOperation> // look for a deletion id getOperation.DeletionId = GeneralHelper.XmlAttributeToInt(element.GetAttribute("did")); return(getOperation); }
internal static WorkingFolder FromXml(Repository repository, XmlReader reader) { string local = TfsPath.ToPlatformPath(reader.GetAttribute("local")); string serverItem = reader.GetAttribute("item"); return(new WorkingFolder(serverItem, local)); }
public VersionControlPath GetServerPathForLocalPath(string localItem) { var mappedFolder = Folders.FirstOrDefault(f => localItem.StartsWith(f.LocalItem, StringComparison.OrdinalIgnoreCase)); if (mappedFolder == null) { return(null); } if (string.Equals(mappedFolder.LocalItem, localItem, StringComparison.OrdinalIgnoreCase)) { return(mappedFolder.ServerItem); } else { string rest = TfsPath.LocalToServerPath(localItem.Substring(mappedFolder.LocalItem.Length)); if (mappedFolder.ServerItem == VersionControlPath.RootFolder) { return("$" + rest); } else { return(mappedFolder.ServerItem + rest); } } }
internal XElement ToXml(XNamespace ns) { return(new XElement(ns + "WorkingFolder", new XAttribute("local", TfsPath.FromPlatformPath(LocalItem)), new XAttribute("item", ServerItem), new XAttribute("type", this.Type.ToString()))); }
internal void ToXml(XmlWriter writer, string element) { if (String.IsNullOrEmpty(item)) { return; } writer.WriteStartElement(element); if (this.RecursionType != RecursionType.None) { writer.WriteAttributeString("recurse", RecursionType.ToString()); } if (this.DeletionId != 0) { writer.WriteAttributeString("did", DeletionId.ToString()); } // only convert local path specs from platform paths to tfs paths if (VersionControlPath.IsServerItem(Item)) { writer.WriteAttributeString("item", Item); } else { writer.WriteAttributeString("item", TfsPath.FromPlatformPath(Item)); } writer.WriteEndElement(); }
internal void ToXml(XmlWriter writer, string element) { writer.WriteStartElement("WorkingFolder"); writer.WriteAttributeString("local", TfsPath.FromPlatformPath(LocalItem)); writer.WriteAttributeString("item", ServerItem); // writer.WriteAttributeString("type", Type.ToString()); writer.WriteEndElement(); }
public XElement ToXml(XNamespace ns) { var el = new XElement(ns + "LocalVersionUpdate", new XAttribute("itemid", ItemId), new XAttribute("lver", LocalVersion)); if (!string.IsNullOrEmpty(TargetLocalItem)) { el.Add(new XAttribute("tlocal", TfsPath.FromPlatformPath(TargetLocalItem))); } return(el); }
internal static WorkingFolder FromXml(XElement element) { string local = TfsPath.ToPlatformPath(element.Attribute("local").Value); string serverItem = element.Attribute("item").Value; var workFolder = new WorkingFolder(serverItem, local); if (element.Attribute("type") != null) { workFolder.Type = (WorkingFolderType)Enum.Parse(typeof(WorkingFolderType), element.Attribute("type").Value); } return(workFolder); }
public void ToXml(XmlWriter writer, string element) { writer.WriteStartElement("LocalVersionUpdate"); writer.WriteAttributeString("itemid", Convert.ToString(itemId)); if (!String.IsNullOrEmpty(targetLocalItem)) { writer.WriteAttributeString("tlocal", TfsPath.FromPlatformPath(targetLocalItem)); } writer.WriteAttributeString("lver", Convert.ToString(localVersion)); writer.WriteEndElement(); }
public string GetLocalPathForServerPath(VersionControlPath serverItem) { var mappedFolder = Folders.FirstOrDefault(f => serverItem.IsChildOrEqualTo(f.ServerItem)); if (mappedFolder == null) { return(null); } if (serverItem == mappedFolder.ServerItem) { return(mappedFolder.LocalItem); } else { //string rest = TfsPath.ServerToLocalPath(serverItem.ToString().Substring(mappedFolder.ServerItem.ToString().Length + 1)); string rest = TfsPath.ServerToLocalPath(serverItem.ChildPart(mappedFolder.ServerItem)); return(Path.Combine(mappedFolder.LocalItem, rest)); } }
internal void ToXml(XmlWriter writer, string element) { writer.WriteStartElement("ChangeRequest"); writer.WriteAttributeString("req", RequestType.ToString()); if (RequestType == RequestType.Lock || LockLevel != LockLevel.None) { writer.WriteAttributeString("lock", LockLevel.ToString()); } if (RequestType == RequestType.Add) { writer.WriteAttributeString("enc", Encoding.ToString()); } writer.WriteAttributeString("type", ItemType.ToString()); //writer.WriteAttributeString("did", DeletionId.ToString()); //writer.WriteAttributeString("targettype", TargetType.ToString()); if (!String.IsNullOrEmpty(Target)) { // convert local path specs from platform paths to tfs paths as needed string fxdTarget; if (VersionControlPath.IsServerItem(Target)) { fxdTarget = Target; } else { fxdTarget = TfsPath.FromPlatformPath(Target); } writer.WriteAttributeString("target", fxdTarget); } this.Item.ToXml(writer, "item"); //this.VersionSpec.ToXml(writer, "vspec"); writer.WriteEndElement(); }
//<ExtendedItem lver="int" did="int" latest="int" //type="Any or Folder or File" enc="int" itemid="int" //local="string" titem="string" sitem="string" //chg="None or Add or Edit or Encoding or Rename or Delete or Undelete or Branch or Merge or Lock" //ochg="boolean" lock="None or Checkin or CheckOut or Unchanged" //lowner="string" /> internal static ExtendedItem FromXml(Repository repository, XmlReader reader) { ExtendedItem item = new ExtendedItem(); string chg = reader.GetAttribute("chg"); if (!String.IsNullOrEmpty(chg)) { item.changeType = (ChangeType)Enum.Parse(typeof(ChangeType), chg, true); } string ochg = reader.GetAttribute("ochg"); if (!String.IsNullOrEmpty(ochg)) { item.hasOtherPendingChange = bool.Parse(ochg); } string xlock = reader.GetAttribute("lock"); if (!String.IsNullOrEmpty(xlock)) { item.lockStatus = (LockLevel)Enum.Parse(typeof(LockLevel), xlock, true); } item.lockOwner = reader.GetAttribute("lowner"); item.localItem = TfsPath.ToPlatformPath(reader.GetAttribute("local")); item.targetServerItem = reader.GetAttribute("titem"); item.sourceServerItem = reader.GetAttribute("sitem"); item.itemType = (ItemType)Enum.Parse(typeof(ItemType), reader.GetAttribute("type"), true); item.itemId = Convert.ToInt32(reader.GetAttribute("itemid")); item.encoding = Convert.ToInt32(reader.GetAttribute("enc")); item.versionLocal = Convert.ToInt32(reader.GetAttribute("lver")); item.versionLatest = Convert.ToInt32(reader.GetAttribute("latest")); item.deletionId = Convert.ToInt32(reader.GetAttribute("did")); return(item); }
//private System.Byte[] hashValue; internal static GetOperation FromXml(string itemUrl, XmlReader reader) { GetOperation getOperation = new GetOperation(); string elementName = reader.Name; string stype = reader.GetAttribute("type"); if (!String.IsNullOrEmpty(stype)) { getOperation.itemType = (ItemType)Enum.Parse(typeof(ItemType), stype, true); } getOperation.itemId = Convert.ToInt32(reader.GetAttribute("itemid")); getOperation.slocal = TfsPath.ToPlatformPath(reader.GetAttribute("slocal")); getOperation.tlocal = TfsPath.ToPlatformPath(reader.GetAttribute("tlocal")); getOperation.titem = reader.GetAttribute("titem"); getOperation.sver = Convert.ToInt32(reader.GetAttribute("sver")); getOperation.lver = Convert.ToInt32(reader.GetAttribute("lver")); string chgAttr = reader.GetAttribute("chg"); if (!String.IsNullOrEmpty(chgAttr)) { getOperation.chg = (ChangeType)Enum.Parse(typeof(ChangeType), chgAttr.Replace(" ", ","), true); } // setup download url if found string durl = reader.GetAttribute("durl"); if (!String.IsNullOrEmpty(durl)) { getOperation.artifactUri = new Uri(String.Format("{0}?{1}", itemUrl, durl)); } // here's what you get if you remap a working folder from one // team project to another team project with the same file // first you get the update getOperation, then you get this later on // <GetOperation type="File" itemid="159025" slocal="foo.xml" titem="$/bar/foo.xml" lver="12002"><HashValue /></GetOperation> // look for a deletion id getOperation.did = Convert.ToInt32(reader.GetAttribute("did")); while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName) { break; } if (reader.NodeType == XmlNodeType.Element && (!reader.IsEmptyElement)) { switch (reader.Name) { case "HashValue": break; } } } return(getOperation); }
internal XElement ToXml(XNamespace ns) { var result = new XElement(ns + "ChangeRequest", new XAttribute("req", RequestType), new XAttribute("type", ItemType)); if (RequestType == RequestType.Lock || LockLevel != LockLevel.None) { result.Add(new XAttribute("lock", LockLevel)); } if (RequestType == RequestType.Add) { result.Add(new XAttribute("enc", Encoding)); } if (!string.IsNullOrEmpty(Target)) { // convert local path specs from platform paths to tfs paths as needed string fxdTarget = VersionControlPath.IsServerItem(Target) ? Target : TfsPath.FromPlatformPath(Target); result.Add(new XAttribute("target", fxdTarget)); } result.Add(this.Item.ToXml(ns + "item")); result.Add(this.VersionSpec.ToXml(ns + "vspec")); return(result); }