示例#1
0
        public void CrawlForImages()
        {
            ConnectionStringSettings s = new ConnectionStringSettings();

            s.ProviderName = SQLiteRegistrar.SQLiteFactoryAssemblyQualifiedName();

            string path = Prompt("Please enter the path to the Analytics database");

            s.ConnectionString = string.Format("Data Source={0};Version=3;", path);

            DefaultConnectionStringResolver.Instance.Resolver = (cn) =>
            {
                if (cn.Equals(Image.ConnectionName(typeof(Image))))
                {
                    OutFormat("Resolved connectionString {0}", s.ConnectionString);
                    return(s);
                }

                OutFormat("Couldn't resolve connectionString for connectionName {0}", cn);
                return(null);
            };
            SQLiteRegistrar.Register <Image>();

            ImageCrawler crawler = new ImageCrawler();

            crawler.OnImageFound = (u, src) =>
            {
                string url = u.ToString();
                OutFormat("Url: {0}\r\n", ConsoleColor.Cyan, url);
                OutFormat("Src: {0}\r\n", ConsoleColor.Green, src);
            };

            crawler.ActionChanged += (cr, args) =>
            {
                OutFormat("{0}::{1}", args.OldAction.ToString(), args.NewAction.ToString());
            };

            string startUrl = Prompt("Enter the starting url");

            crawler.Name = startUrl;
            Crawler data = new Crawler();

            data.Name    = startUrl;
            data.RootUrl = startUrl;
            data.Save();
            crawler.Crawl(startUrl);
        }
示例#2
0
        public override ConnectionStringResolveResult ResolveConnectionString(string connectionName)
        {
            try
            {
                Args.ThrowIfNull(VaultFile, "VaultFile");

                ConnectionStringSettings s = new ConnectionStringSettings();
                s.ProviderName     = SQLiteRegistrar.SQLiteFactoryAssemblyQualifiedName();
                s.ConnectionString = string.Format("Data Source={0};Version=3;", VaultFile.FullName);

                return(new ConnectionStringResolveResult(s));
            }
            catch (Exception ex)
            {
                return(new ConnectionStringResolveResult(null, ex));
            }
        }