void LoadBookmarks() { using (new ScopedGuard(() => loadingLogSourceInfoFromStorageEntry = true, () => loadingLogSourceInfoFromStorageEntry = false)) using (var section = logSourceSpecificStorageEntry.OpenXMLSection("bookmarks", Persistence.StorageSectionOpenFlag.ReadOnly)) { var root = section.Data.Element("bookmarks"); if (root == null) { return; } foreach (var elt in root.Elements("bookmark")) { var time = elt.Attribute("time"); var thread = elt.Attribute("thread-id"); var name = elt.Attribute("display-name"); var position = elt.Attribute("position"); var lineIndex = elt.Attribute("line-index"); if (time != null && thread != null && name != null && position != null) { bookmarks.ToggleBookmark(bookmarks.Factory.CreateBookmark( MessageTimestamp.ParseFromLoselessFormat(time.Value), logSourceThreads.GetThread(new StringSlice(thread.Value)), name.Value, long.Parse(position.Value), (lineIndex != null) ? int.Parse(lineIndex.Value) : 0 )); } } } }
public static bool TryParse(string str, out ITimeOffsets value) { value = null; if (str == null) { return(false); } var entries = new List <Entry>(); bool firstPart = true; foreach (var part in str.Split(',')) { var entry = new Entry(); if (firstPart) { firstPart = false; if (!TimeSpan.TryParseExact(part, "c", null, out entry.offset)) { return(false); } entry.at = DateTime.MinValue; } else { var components = part.Split('='); if (components.Length != 2) { return(false); } if (!TimeSpan.TryParseExact(components[1], "c", null, out entry.offset)) { return(false); } entry.at = MessageTimestamp.ParseFromLoselessFormat(components[0]).ToUnspecifiedTime(); } entries.Add(entry); } if (entries.Count == 0) { return(false); } entries.Sort((e1, e2) => Math.Sign(e2.at.Ticks - e1.at.Ticks)); value = new TimeOffsets(entries); return(true); }