internal static ItemSecurity FromXml(Repository repository, XmlReader reader) { ItemSecurity itemSecurity = new ItemSecurity(); string elementName = reader.Name; itemSecurity.serverItem = reader.GetAttribute("item"); itemSecurity.writable = Convert.ToBoolean(reader.GetAttribute("writable")); List<AccessEntry> entries = new List<AccessEntry>(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName) break; if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "AccessEntry": entries.Add(AccessEntry.FromXml(repository, reader)); break; } } } itemSecurity.entries = entries.ToArray(); return itemSecurity; }
public TFSRevision(Repository repo, string itemPath, Changeset changeset) : this(repo, changeset.ChangesetId, itemPath) { this.Author = changeset.Committer; this.Message = changeset.Comment; this.Time = changeset.CreationDate; }
internal static AccessEntry FromXml(Repository repository, XmlReader reader) { AccessEntry entry = new AccessEntry(); string elementName = reader.Name; entry.ident = reader.GetAttribute("ident"); while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName) break; if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "Allow": entry.allow = ReadPermissions(reader); break; case "Deny": entry.deny = ReadPermissions(reader); break; case "AllowInherited": entry.allowInherited = ReadPermissions(reader); break; case "DenyInherited": entry.denyInherited = ReadPermissions(reader); break; } } } return entry; }
internal static ItemSet FromXml(Repository repository, XmlReader reader) { string elementName = reader.Name; ItemSet itemSet = new ItemSet(); List<Item> items = new List<Item>(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName) break; if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "Item": items.Add(Item.FromXml(repository, reader)); break; case "Pattern": itemSet.pattern = reader.ReadElementContentAsString(); break; case "QueryPath": itemSet.queryPath = reader.ReadElementContentAsString(); break; } } } items.Sort(Item.GenericComparer); itemSet.items = items.ToArray(); return itemSet; }
public static void WriteTo(string fileName, Repository repository, Uri artifactUri) { int n; byte[] bytes = new byte[4096]; // setup request HttpWebRequest request = (HttpWebRequest) WebRequest.Create(artifactUri); request.Credentials = repository.Credentials; request.Timeout = 90000; //request.KeepAlive = false; //request.ProtocolVersion = HttpVersion.Version10; // write output to file string tempFileName = Path.GetTempFileName(); string contentType; using (WebResponse response = request.GetResponse()) { contentType = response.ContentType; using (Stream stream = response.GetResponseStream()) { using (BinaryWriter writer = new BinaryWriter(File.Create(tempFileName))) { while ((n = stream.Read(bytes, 0, bytes.Length)) != 0) { writer.Write(bytes, 0, n); } } } } // clear out old file as needed if (File.Exists(fileName)) { File.SetAttributes(fileName, FileAttributes.Normal); File.Delete(fileName); } // do we need to decompress the data? if (contentType != "application/gzip") File.Move(tempFileName, fileName); else { // note: mono stackdumped when i tried to do GZipStream over response.GetResponseStream // with thousands of files (see: http://lists.ximian.com/pipermail/mono-devel-list/2007-March/022712.html) // so this may not be as fast, but it works using (GZipStream stream = new GZipStream(File.OpenRead(tempFileName), CompressionMode.Decompress)) { using (BinaryWriter writer = new BinaryWriter(File.Create(fileName))) { while ((n = stream.Read(bytes, 0, bytes.Length)) != 0) { writer.Write(bytes, 0, n); } } } File.Delete(tempFileName); } }
//internal event FileTransferEventHandler Uploading; public VersionControlServer(TeamFoundationServer teamFoundationServer) { ICredentials credentials = teamFoundationServer.Credentials; this.teamFoundationServer = teamFoundationServer; this.uri = teamFoundationServer.Uri; this.repository = new Repository(this, uri, credentials); if (credentials != null) this.authenticatedUser = credentials.GetCredential(uri, "").UserName; }
internal static Change FromXml(Repository repository, XmlReader reader) { Change change = new Change(); string chgAttr = reader.GetAttribute("chg"); if (String.IsNullOrEmpty(chgAttr)) { chgAttr = reader.GetAttribute("type"); } change.changeType = (ChangeType) Enum.Parse(typeof(ChangeType), chgAttr.Replace(" ", ","), true); reader.Read(); change.item = Item.FromXml(repository, reader); return change; }
internal static Annotation FromXml(Repository repository, XmlReader reader) { string elementName = reader.Name; Annotation annotation = new Annotation(); annotation.item = reader.GetAttribute("item"); annotation.version = Convert.ToInt32(reader.GetAttribute("v")); annotation.name = reader.GetAttribute("name"); annotation.value = reader.GetAttribute("value"); string date = reader.GetAttribute("date"); if (!String.IsNullOrEmpty(date)) annotation.date = DateTime.Parse(date); while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName) break; if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "Comment": annotation.comment = reader.ReadString(); break; } } } return annotation; }
//<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; }
public override IRepositoryEditor CreateRepositoryEditor(Repository repo) { return new TFSRepositoryEditor((TFSRepository)repo); }
internal static Changeset FromXml(Repository repository, XmlReader reader) { string elementName = reader.Name; Changeset changeset = new Changeset(); changeset.versionControlServer = repository.VersionControlServer; changeset.committer = reader.GetAttribute("cmtr"); changeset.changesetId = Convert.ToInt32(reader.GetAttribute("cset")); string date = reader.GetAttribute("date"); changeset.creationDate = DateTime.ParseExact(date, DateTimeFormats, null, DateTimeStyles.None); changeset.owner = reader.GetAttribute("owner"); List<Change> changes = new List<Change>(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName) break; if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "Change": changes.Add(Change.FromXml(repository, reader)); break; case "Comment": changeset.comment = reader.ReadString(); break; } } } changeset.changes = changes.ToArray(); return changeset; }
internal static Workspace FromXml(Repository repository, XmlReader reader) { string elementName = reader.Name; string computer = reader.GetAttribute("computer"); string name = reader.GetAttribute("name"); string owner = reader.GetAttribute("owner"); string comment = ""; DateTime lastAccessDate = DateTime.Now; List<WorkingFolder> folders = new List<WorkingFolder>(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName) break; if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "WorkingFolder": folders.Add(WorkingFolder.FromXml(repository, reader)); break; case "Comment": comment = reader.ReadString(); break; case "LastAccessDate": lastAccessDate = reader.ReadElementContentAsDateTime(); break; } } } Workspace w = new Workspace(repository.VersionControlServer, name, owner, comment, folders.ToArray(), computer); w.lastAccessDate = lastAccessDate; return w; }
public TFSRevision(Repository repo, int version, string itemPath) : base(repo) { this.Version = version; this.ItemPath = itemPath; }
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); }
internal static ChangesetMerge FromXml(Repository repository, XmlReader reader) { ChangesetMerge merge = new ChangesetMerge(); merge.sourceVersion = Convert.ToInt32(reader.GetAttribute("srcver")); merge.targetVersion = Convert.ToInt32(reader.GetAttribute("tgtver")); merge.partialFlag = Convert.ToBoolean(reader.GetAttribute("part")); return merge; }
internal static BranchRelative FromXml(Repository repository, XmlReader reader) { string elementName = reader.Name; BranchRelative branch = new BranchRelative(); branch.relativeToItemId = Convert.ToInt32(reader.GetAttribute("reltoid")); branch.relativeFromItemId = Convert.ToInt32(reader.GetAttribute("relfromid")); branch.isRequestedItem = Convert.ToBoolean(reader.GetAttribute("reqstd")); while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName) break; if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "BranchFromItem": branch.branchFromItem = Item.FromXml(repository, reader); break; case "BranchToItem": branch.branchToItem = Item.FromXml(repository, reader); break; } } } return branch; }
internal static VersionControlLabel FromXml(Repository repository, XmlReader reader) { VersionControlLabel label = new VersionControlLabel(); string elementName = reader.Name; label.lastModifiedDate = DateTime.Parse(reader.GetAttribute("date")); label.name = reader.GetAttribute("name"); label.ownerName = reader.GetAttribute("owner"); label.scope = reader.GetAttribute("scope"); label.labelId = Convert.ToInt32(reader.GetAttribute("lid")); List<Item> items = new List<Item>(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName) break; if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "Item": items.Add(Item.FromXml(repository, reader)); break; case "Comment": label.comment = reader.ReadString(); break; } } } label.items = items.ToArray(); return label; }
internal static RepositoryProperties FromXml(Repository repository, XmlReader reader) { RepositoryProperties repositoryProperties = new RepositoryProperties(); repositoryProperties.id = reader.GetAttribute("id"); repositoryProperties.name = reader.GetAttribute("name"); repositoryProperties.ver = reader.GetAttribute("ver"); repositoryProperties.latestChangesetId = Convert.ToInt32(reader.GetAttribute("lcset")); return repositoryProperties; }
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; }