public void SetPageCalculation(LinkRelationship relationship,
                                Func <PaginationInfo, Uri> function)
 => _pageDataCalculators[relationship.GetLinkHeaderValue()] = info => new PageData
 {
     PageLink             = function(info),
     LinkRelationshipType = relationship.GetLinkHeaderValue()
 };
Example #2
0
 public Link(Uri href, string title, LinkRelationship relationship, string type)
 {
     _href = href;
     _title = title;
     _relationship = relationship;
     _type = type;
 }
Example #3
0
        /// <summary>
        /// Adds a new LinkRelationship to the Model.
        /// </summary>
        /// <param name="link">The Link object associated with the new LinkRelationship.</param>
        /// <param name="dataSource">The DataSource to which the LinkRelationship will be added.</param>
        private void AddLinkRelationshipToModel(Link link, DataSource dataSource)
        {
            LinkRelationship linkRelationship = Model.AddLinkRelationship(link, dataSource);

            // Add View Model.
            if (LinkRelationshipsVM.LinkRelationships == null)
            {
                throw new InvalidOperationException("LinkRelationships was null!");
            }

            // MainViewModel knows about LinkRelationShipVM AND has access to the new linkRelationship.
            // That's why it makes sense to do this here.
            LinkRelationshipsVM.LinkRelationships.Add(new LinkRelationshipViewModel(linkRelationship));
        }
Example #4
0
 public static string GetRelationshipAttributeValue(LinkRelationship rel)
 {
     switch (rel)
     {
         case LinkRelationship.Alternate:
             return LinkAlternateAttributeValue;
         case LinkRelationship.Enclosure:
             return LinkEnclosureAttributeValue;
         case LinkRelationship.Related:
             return LinkRelatedAttributeValue;
         case LinkRelationship.Self:
             return LinkSelfAttributeValue;
         case LinkRelationship.Via:
             return LinkViaAttributeValue;
         case LinkRelationship.None:
         default:
             return LinkNoneAttributeValue;
     }
 }
Example #5
0
 public RemoveLinkRelationship(LinkRelationship linkRelationship, DataSource dataSource)
 {
     LinkRelationship = linkRelationship;
     DataSource       = dataSource;
 }
Example #6
0
 public Link(Uri href, string title, LinkRelationship relationship)
     : this(href, title, relationship, null)
 {
 }
Example #7
0
 public Link(Uri href, LinkRelationship relationship)
     : this(href, null, relationship, null)
 {
 }
 public LinkRelationshipViewModel(LinkRelationship linkRelationship)
 {
     LinkRelationship = linkRelationship;
 }
Example #9
0
 /// <summary>
 /// Adds a new LinkRelationship to the Model.
 /// </summary>
 /// <param name="link">The Link object associated with the new LinkRelationship.</param>
 /// <param name="dataSource">The DataSource to which the LinkRelationship will be added.</param>
 private static void RemoveLinkRelationshipFromModel(LinkRelationship link, DataSource dataSource)
 {
     Model.RemoveLinkRelationship(link, dataSource);
 }
Example #10
0
 public IEnumerable<Link> GetLinks(LinkRelationship relationship)
 {
     foreach (Link link in this.Links)
         if (link.Relationship == relationship)
             yield return link;
 }