コード例 #1
0
        public IBlog GetBlog(string blogUrl, string path, string filenameTemplate)
        {
            blogUrl = _urlValidator.AddHttpsProtocol(blogUrl);
            if (_urlValidator.IsValidTumblrUrl(blogUrl))
            {
                return(TumblrBlog.Create(blogUrl, path, filenameTemplate));
            }

            if (_urlValidator.IsTumbexUrl(blogUrl))
            {
                return(TumblrBlog.Create(CreateTumblrUrlFromTumbex(blogUrl), path, filenameTemplate));
            }

            if (_urlValidator.IsValidTumblrHiddenUrl(blogUrl))
            {
                return(TumblrHiddenBlog.Create(blogUrl, path, filenameTemplate));
            }

            if (_urlValidator.IsValidTumblrLikedByUrl(blogUrl))
            {
                return(TumblrLikedByBlog.Create(blogUrl, path, filenameTemplate));
            }

            if (_urlValidator.IsValidTumblrSearchUrl(blogUrl))
            {
                return(TumblrSearchBlog.Create(blogUrl, path, filenameTemplate));
            }

            if (_urlValidator.IsValidTumblrTagSearchUrl(blogUrl))
            {
                return(TumblrTagSearchBlog.Create(blogUrl, path, filenameTemplate));
            }

            throw new ArgumentException("Website is not supported!", nameof(blogUrl));
        }
コード例 #2
0
ファイル: BlogFactory.cs プロジェクト: magichaotu/TumblThree
 public IBlog GetBlog(string blogUrl, string path)
 {
     if (Validator.IsValidTumblrUrl(blogUrl))
     {
         return(Blog.Create(blogUrl, path, BlogTypes.tumblr));
     }
     if (Validator.IsValidTumblrLikedByUrl(blogUrl))
     {
         return(TumblrLikeByBlog.Create(blogUrl, path, BlogTypes.tlb));
     }
     if (Validator.IsValidTumblrSearchUrl(blogUrl))
     {
         return(TumblrSearchBlog.Create(blogUrl, path, BlogTypes.tumblrsearch));
     }
     if (Validator.IsValidTumblrTagSearchUrl(blogUrl))
     {
         return(TumblrTagSearchBlog.Create(blogUrl, path, BlogTypes.tumblrtagsearch));
     }
     throw new ArgumentException("Website is not supported!", nameof(blogUrl));
 }