private static List <Comment> ParseThread(XElement threadElem, ParatextUser ptUser) { List <Comment> result = new List <Comment>(); Comment comment = null; foreach (var commentElem in threadElem.Elements("comment")) { if (comment == null) { comment = new Comment(ptUser); XAttribute threadId = threadElem.Attribute("id"); if (threadId != null) { comment.Thread = threadId.Value; } ParseSelection(threadElem.Element("selection"), comment); } else { comment = (Comment)comment.Clone(); } result.Add(comment); ParseComment(commentElem, comment); } return(result); }
public MockScrText(ParatextUser associatedPtUser, ProjectName projectName) : base(associatedPtUser) { this.projectName = projectName; Settings = new MockProjectSettings(this); // ScrText sets its cachedGuid from the settings Guid. Here we are doing it the other way around. // Some tests may need both MockScrText.Guid and MockScrText.Settings.Guid to be set. _language = new MockScrLanguage(this); }
/// <summary> /// Parses the XML into a nested list of Comments - each inner list is the data for a thread. /// </summary> /// <param name="noteXml"></param> /// <param name="ptUser">ParatextUser to use when creating any new Comments.</param> /// <returns>Nested list of comments</returns> /// <remarks>This code assumes that the XML passes the validation of the notes XML schema.</remarks> public static List <List <Comment> > ParseNotes(string noteXml, ParatextUser ptUser) { List <List <Comment> > result = new List <List <Comment> >(); XDocument doc = XDocument.Parse(noteXml); foreach (var threadElem in doc.Root.Elements("thread")) { result.Add(ParseThread(threadElem, ptUser)); } return(result); }
public JwtInternetSharedRepositorySource(string accessToken, JwtRestClient registryClient, ParatextUser authenticationPtUser, string srServerUri) : base(authenticationPtUser, srServerUri) { _registryClient = registryClient; SetToken(accessToken); }