private void LoadComments(Section section) { section.Clear(); if (_comments == null) { return; } foreach (var comment in _comments) { try { var thisComment = comment; var sse = new Gistacular.Elements.NameTimeStringElement() { Time = thisComment.CreatedAt, String = thisComment.Body, Lines = 4, Image = Images.Misc.Anonymous, }; sse.Name = thisComment.User == null ? "Unknown" : thisComment.User.Login; sse.ImageUri = (thisComment.User == null) ? null : new Uri(thisComment.User.AvatarUrl); section.Add(sse); } catch (Exception e) { Utilities.LogException("Unable to load comments!", e); } } }
public static Gistacular.Elements.NameTimeStringElement CreateGistElement(GistModel x) { var str = string.IsNullOrEmpty(x.Description) ? "No Description" : x.Description; var sse = new Gistacular.Elements.NameTimeStringElement() { Time = x.UpdatedAt, String = str, Lines = 4, Image = Images.Misc.Anonymous, Tag = x, }; //We prefer the filename, so lets try and get it if it exists string filename = null; if (x.Files.Count > 0) { var iter = x.Files.Keys.GetEnumerator(); iter.MoveNext(); filename = iter.Current; } //Set the name (If we have no filename, fall back to the username) sse.Name = (filename == null) ? (x.User == null ? "Unknown" : x.User.Login) : filename; sse.ImageUri = (x.User == null) ? null : new Uri(x.User.AvatarUrl); return(sse); }