public async Task <bool> PrepareAsync(CookieAwareWebClient client, CancellationToken cancellation) { var url = await GetRedirectOverrideAsync(_url, client, cancellation); if (url == null || cancellation.IsCancellationRequested) { return(false); } _url = url; Logging.Write($"{GetType().Name} download link: {_url}"); _innerLoader = await FlexibleLoader.CreateLoaderAsync(_url, this, cancellation); if (_innerLoader == null || cancellation.IsCancellationRequested) { return(false); } if (_innerLoader.GetType() == GetType()) { throw new Exception(ToolsStrings.DirectLoader_RecursionDetected); } return(await _innerLoader.PrepareAsync(client, cancellation)); }
public void Dispose() { if (typeof(IDisposable).IsAssignableFrom(loader.GetType())) { ((IDisposable)loader).Dispose(); } }
protected void run(Arguments arg, IExtractor extractor, ITransformer transformer, ILoader loader) { DataTable data = null; Logger.info(extractor.GetType().ToString() + " Extraction Start"); extractor.setArgs(arg); data = extractor.extract(); Logger.info(transformer.GetType().ToString() + " Transformation Start"); transformer.setArgs(arg); data = transformer.transform(data); Logger.info(loader.GetType().ToString() + " Loading Start"); loader.setArgs(arg); loader.load(data); Logger.info(loader.GetType().ToString() + " Loading Complete"); }
public void TestFileLoaderReturn() { ILoaderFactory factory = new LoaderFactory(); Mock <ILoaderConfiguration> testConfig = new Mock <ILoaderConfiguration>(); testConfig.Setup(x => x.LoaderType).Returns(LoaderTypeEnum.FileLoader); ILoader loader = factory.GetLoader(testConfig.Object); Assert.AreEqual(typeof(FileLoader), loader.GetType()); }
static void RunResourceLoader() { Console.WriteLine("Please enter url"); var urlString = Console.ReadLine(); if (!string.IsNullOrWhiteSpace(urlString)) { Console.WriteLine("Please select type of loader:\nA - WebClientLoader\nB - HttpWebRequestLoader"); //pattern Fabric ILoader loader = LoaderFactory.Create(Console.ReadKey().Key); Console.WriteLine(" - will be used -> {0} ", loader.GetType().Name); string resultOfLoad = string.Empty; try { resultOfLoad = loader.Load(new Uri(urlString)); } catch (ResourseNotLoadedException ex) { Console.WriteLine(ex.ToString()); } if (!string.IsNullOrWhiteSpace(resultOfLoad)) { Console.WriteLine("Website as string:\n{0}", resultOfLoad); } else { Console.WriteLine("The webClientLoader returned an empty string"); } } else { Console.WriteLine("Url is not valid"); Console.ReadLine(); return; } }