コード例 #1
0
        public Link RenderLink(PaperContext ctx)
        {
            var paper = ctx.Injector.CreateInstance <T>();

            setup?.Invoke(paper);

            var link = new Link
            {
                Href = CreateHref(ctx, paper)
            };

            if (paper._Has <string>("GetTitle"))
            {
                link.Title = paper._Call <string>("GetTitle");
            }

            builder?.Invoke(link);

            if (title != null)
            {
                link.Title = title;
            }

            if (rel != null)
            {
                link.AddRel(rel);
            }

            if (link.Rel?.Any() != true)
            {
                link.AddRel(RelNames.Link);
            }

            return(link);
        }
コード例 #2
0
 public virtual void UpdateLinkMethodInfo(Link link)
 {
     if (NotImplemented)
     {
         link.AddRel <NotImplementedRelation>();
     }
     if (IsExperimental)
     {
         link.AddRel <ExperimentalRelation>();
     }
     link.AddRel(this);
     link.SetDescription(Description);
 }
コード例 #3
0
        public static Entity SetSelfLink(this Entity entity, Href href, Action <Link> options = null)
        {
            var self = new Link();

            self.AddRel(Rel.Self);
            self.Href = href;

            var links = entity.WithLinks();

            links.RemoveWhen(x => x.Rel.Has(Rel.Self));
            links.Add(self);

            options?.Invoke(self);

            return(entity);
        }
コード例 #4
0
        public static Entity AddLink(this Entity entity, Href href, Action <Link> options = null)
        {
            var link = new Link {
                Href = href
            };

            entity.WithLinks().Add(link);

            options?.Invoke(link);

            if (link.WithRel().Count == 0)
            {
                link.AddRel(Rel.Link);
            }
            return(entity);
        }
コード例 #5
0
ファイル: LinkTest.cs プロジェクト: tbossi/Tags
 public void AddRel()
 {
     _tag.AddRel(LinkRel.Alternate);
     Assert.AreEqual(_tag.ToString(), "<link href=\"http://url\" rel=\"alternate\">");
 }