コード例 #1
0
        public async Task <CombResponse> Brush(CombRequest request)
        {
            var response = Validate(request, new CombResponse());

            if (!response.Success)
            {
                return(response);
            }

            var urlDomain = GetUrlDomain(request);
            var link      = new CombLink(request.Url, urlDomain);

            await Brush(link, urlDomain, request.Depth);

            response.Result = link;
            return(response);
        }
コード例 #2
0
        private CombResponse Validate(CombRequest request, CombResponse response)
        {
            try
            {
                if (string.IsNullOrEmpty(request.Url) ||
                    !request.Url.StartsWith(Uri.UriSchemeHttp) ||
                    !Uri.IsWellFormedUriString(request.Url, UriKind.RelativeOrAbsolute) ||
                    string.IsNullOrEmpty(GetUrlDomain(request)))
                {
                    response.Errors.Add("Invalid Url");
                }
            }
            catch
            {
                response.Errors.Add("Invalid Url");
            }

            return(response);
        }
コード例 #3
0
 private string GetUrlDomain(CombRequest request)
 {
     return(new Uri(request.Url).GetLeftPart(UriPartial.Authority));
 }