コード例 #1
0
        public IEnumerable <string> Run(string url, uint depth, IServiceProvider provider, string prefix = "")
        {
            var resultLinks = new List <string>();

            url = _urlProtocolHandler.Handle(url);

            if (!_urlValidator.Validate(url))
            {
                throw new ArgumentException("Your entered URL was not valid!");
            }

            var retriever = RetrieverFactory.GetRetriever("Html", provider);
            var html      = retriever.Retrieve(url);

            var htmlReader = ReaderFactory.GetReader("Html");
            var links      = htmlReader.GetLinksFromText(html);

            if (depth == 0)
            {
                return(links);
            }

            links.ToList().ForEach(link =>
            {
                resultLinks.Add(link);

                uint decreasedDepth = depth - 1;
                var childResult     = Run(link, decreasedDepth, provider, "-");
                resultLinks.AddRange(childResult);
            });

            return(resultLinks);
        }
コード例 #2
0
        public static void UpdateDns(IProviderPlugin updateStrategy, IDictionary <String, Object> config)
        {
            IPAddress ipAddress = default;

            IDynLogger logger = new DynConsoleLogger();

            IAddressRetriever retriever = RetrieverFactory.GetRetriever(RetrieverType.Http);

            while (ipAddress == default)
            {
                ipAddress = retriever.GetAddress();
            }

            updateStrategy.Logger = logger;
            updateStrategy.Update(ipAddress, config);
        }
コード例 #3
0
        public void ShouldThrowNotSupportedExceptionWhenReaderIsNotSupported()
        {
            Action reader = () => RetrieverFactory.GetRetriever("hans", _providers);

            reader.Should().Throw <NotSupportedException>();
        }
コード例 #4
0
        public void ShouldReturnHtmlRetrieverFromFactory()
        {
            var retriever = RetrieverFactory.GetRetriever("html", _providers);

            retriever.Should().BeOfType <HtmlRetriever>();
        }