private static string GetUriFromLinkRelation(Linkable sourceModel, string linkRel) { string uri = LinkRelations.FindLinkAsString(sourceModel.Links, linkRel); if (uri != null && uri.Contains("{")) { uri = uri.Substring(0, uri.IndexOf("{")); } return(uri); }
/// <summary> /// Gets the results of a request and converts them to a LIST /// </summary> /// <typeparam name="T">The type of list to be returned</typeparam> /// <param name="feed">The feed to be converted</param> /// <param name="fetchFullObject">Whether or not to fetch the full object(s) or just convert the feed to a list</param> /// <returns></returns> public static List <T> getFeedAsList <T>(Feed <T> feed, bool fetchFullObject) { List <T> list = new List <T>(); List <Entry <T> > entries = feed.Entries; foreach (Entry <T> entry in entries) { T content = entry.Content; T fullContent = default(T); { if (content is Linkable && fetchFullObject) { Linkable linkable = content as Linkable; if (linkable.Links.Count > 0) { Link self = LinkRelations.FindLink((content as Linkable).Links, LinkRelations.SELF.Rel); if (self == null) { self = (content as Linkable).Links[0]; } fullContent = feed.Client.Get <T>(self.Href, null); } else { fullContent = content; } } else { fullContent = content; } } if (content is Executable) { (fullContent as Executable).SetClient(feed.Client); } list.Add(fullContent); } return(list); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="feed"></param> /// <param name="title"></param> /// <returns></returns> public static string FindEntryHref <T>(Feed <T> feed, string title) { string href = null; List <Entry <T> > entries = feed.Entries; if (entries != null) { foreach (Entry <T> entry in entries) { if (title.Equals(entry.Title) && entry.Content is OutlineAtomContent) { OutlineAtomContent ct = entry.Content as OutlineAtomContent; href = ct.Src; if (href == null) { href = LinkRelations.FindLinkAsString(entry.Links, LinkRelations.SELF.Rel); } break; } } } return(href); }