Ejemplo n.º 1
0
 public bool AreEqual(Uri uri, Link link)
 {
     if (link == null)
     {
         return false;
     }
     Uri linkUri = httpHelper.ConvertToUri(link.ReferenceUri);
     bool equality = uri == linkUri;
     return equality;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Crawls an HTML document building metadata based on conventions or using a best-guess approach.
        /// </summary>
        internal virtual Link CreateLinkFromHtmlDocument(HtmlDocument document, Uri uri)
        {
            RemoveUndesirableTags(document);

            string title = CrawlUsingMetadata(XPath.ResourceTitle, document);
            string description = GetDescriptionFor(document);
            string picture = GetPictureFor(document, uri);

            Link link = new Link
            {
                Created = DateTime.UtcNow,
                ReferenceUri = uri.AbsoluteUri,
                Type = LinkType.Html,
                Title = HtmlEntity.DeEntitize(title),
                Description = HtmlEntity.DeEntitize(description),
                Picture = picture
            };
            return link;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Saves the image to the file system and stores the path in the link entity.
 /// </summary>
 internal virtual Link CreateLinkFromImageSource(Image image, Uri uri)
 {
     Link link = new Link
     {
         Created = DateTime.UtcNow,
         ReferenceUri = uri.AbsoluteUri,
         Type = LinkType.Image
     };
     return link;
 }
Ejemplo n.º 4
0
 private bool VerifyLinkIsHtml(Link link)
 {
     return !link.Title.NullOrEmpty() || !link.Description.NullOrEmpty() || !link.Picture.NullOrEmpty();
 }
Ejemplo n.º 5
0
 public Post Create(Link link, string message, User user)
 {
     Post post = postRepository.Insert(link, message, user);
     return post;
 }