public void AddWebsite(WebsiteType type, WebsiteService service, string address, string url) { if (_websites == null) { _websites = new List <Website>(1); } _websites.Add(Website.Create(type, service, address, url)); }
/// <summary> /// 构造函数 /// </summary> /// <param name="websiteType">网站类型</param> /// <param name="tag">搜索标签</param> public PictureItems(WebsiteType websiteType, string tag = "") { noMorePicture = false; DB = new DataBase(GlobalConfig.DataBaseName); website = new Services.WebsiteHelper(websiteType, tag); loadAll = ServiceLocator.Current.GetInstance <UserConfigVM>().Config.Rating == RatingType.All; // initial load some if (!Busy) { LoadMoreItemsAsync(100); } }
public static string ToFriendlyString(this WebsiteType me) { switch (me) { case WebsiteType.Home: return("home"); case WebsiteType.Work: return("work"); default: return(""); } }
public static Website GetWebsite(WebsiteType type) { switch (type) { case WebsiteType.BLOG: return(new Blog()); case WebsiteType.SHOP: return(new Shop()); default: return(null); } }
public static Website Create(WebsiteType type, WebsiteService service, string address, string url) { if (string.IsNullOrEmpty(address)) { throw new ArgumentException("Address must be populated"); } return(new Website() { Service = service.ToFriendlyString(), Type = type.ToFriendlyString(), Address = address, Url = url }); }
public static Website GetWebsite(WebsiteType siteType) { switch (siteType) { case CreationalDesignPatterns.Entities.FactoryMethod.WebSite.WebsiteType.BLOG: { return(new Blog()); } case CreationalDesignPatterns.Entities.FactoryMethod.WebSite.WebsiteType.SHOP: { return(new Shop()); } default: { return(null); } } }
public static Website createWebsite(WebsiteType type) { switch (type) { case WebsiteType.aLotOfText: return(new ALotOfText()); case WebsiteType.contacts: return(new Contacts()); case WebsiteType.news: return(new News()); case WebsiteType.photoGallery: return(new Gallery()); default: break; } return(null); }
private static void GenerateRandomPage() { Console.WriteLine("Press any key to generate random html website"); Console.ReadKey(); Array values = Enum.GetValues(typeof(WebsiteType)); Random random = new Random(); Website website; WebsiteType type = (WebsiteType)values.GetValue(random.Next(values.Length)); website = WebsiteFactory.createWebsite(type); string code = pageStart(type) + website.pageCode() + pageEnd(); Console.WriteLine(code); string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); //string mydocpath = Environment.CurrentDirectory; File.WriteAllText(@"D:\Szkoła\NJPO" + type.ToString() + ".html", code); Console.WriteLine(@"D:\Szkoła\NJPO\" + type.ToString() + ".html"); Console.ReadKey(); Console.Clear(); GenerateRandomPage(); }
public async void DisplayBulkHeadLines(WebsiteType type, int headlines) { int countSites = 0; List <Website> allSites = TheInternet.ReadFile(type); int totalSites = (allSites.Count() == 0) ? 1:allSites.Count(); if (this.listView.Items.Count > 0) { this.listView.Items.Clear(); } if (this.sitelistBox.Items.Count > 0) { this.sitelistBox.Items.Clear(); } PopulateSiteListbox(); foreach (var site in allSites) { Tools.DebugTrace("siteloop", Thread.CurrentThread.ManagedThreadId); countSites++; var data = await Task.Run(() => Downloader.DownloadHtml(site)); var listView = data.ToObservable() .ObserveOn(Dispatcher) .Where(x => x.Length > 5) .Select(x => x.Trim()) .Take(headlines) .Subscribe(x => PopulateView(site, x)); statusLabel = data.ToObservable() .ObserveOn(Dispatcher) .Subscribe(x => PopulateLabel($"From {site.SiteName} | Feteched {countSites} of {totalSites}")); } statusLabel.Dispose(); }
public static List <Website> ReadFile(WebsiteType type) { return((type == 0) ? ReadFile() : ReadFile() .Where(s => s.Category == type) .ToList()); }
private static string pageStart(WebsiteType webType) { return("<html>\n<head>\n<title>" + webType.ToString() + "</title>\n</head>\n<body>\n"); }