static bool Ft_Check_Equals_Pic(List <Id_Picture> mas, Id_Picture obj) { foreach (Id_Picture item in mas) { if (String.Equals(item.id, obj.id) == true) { return(false); } } return(true); }
static int Ft_Final_Rec_Pic(List <IWebElement> webElements, IWebElement iteam, List <string> list_id, int col, int i, bool flag) { string id; id = iteam.FindElement(By.CssSelector("._post.post")).GetAttribute("id"); list_id.Add(id); List <string> str = new List <string>(); List <IWebElement> Exploer = iteam.FindElements(By.TagName("a")).ToList(); foreach (IWebElement web in Exploer) { if (web.GetAttribute("style") != null && web.GetAttribute("style") != "") { str.Add(web.GetAttribute("style")); } } Id_Picture pic = new Id_Picture(id, str); DataContractJsonSerializer jsonFormatter = new DataContractJsonSerializer(typeof(List <Id_Picture>)); List <Id_Picture> mas = new List <Id_Picture>(); FileInfo fileInfo = new FileInfo(@"E:\institute\operating-system\Chrome\WindowsFormsApp1\WindowsFormsApp1\bin\Debug\ID_Picture.json"); if (flag == true) { mupic.WaitOne(); } FileStream fs1 = new FileStream(@"E:\institute\operating-system\Chrome\WindowsFormsApp1\WindowsFormsApp1\bin\Debug\ID_Picture.json", FileMode.OpenOrCreate); if (fileInfo.Length > 0) { mas = jsonFormatter.ReadObject(fs1) as List <Id_Picture>; } if (Ft_Check_Equals_Pic(mas, pic) == true) { mas.Add(pic); fs1.Position = 0; jsonFormatter.WriteObject(fs1, mas); i++; } fs1.Close(); if (flag == true) { mupic.ReleaseMutex(); } return(i); }