/// <summary> /// Gathers the names of buttons to include in the program from the buttons.xml file. /// Add the counting logic with razor syntax to _CountView.cshtml for the different buttons. /// </summary> /// <returns>List of button names from xml file.</returns> private List <string> GetButtonsFromXml() { MyXmlReader myXmlReader = new MyXmlReader(); List <string> buttons = myXmlReader.GetButtonsFromXml(); return(buttons); }
// Use this for initialization void Awake() { //Read the xml file using the dll MyXmlReader MyXmlReader xmlreader = gameObject.AddComponent <MyXmlReader> (); languages = xmlreader.ReadXml(dictonary); }
void Awake() { #region Make the object persistent if (setupLanguage == null) { DontDestroyOnLoad(gameObject); setupLanguage = this; } else if (setupLanguage != this) { Destroy(gameObject); } #endregion FindGameSetupLangue(); // Set initial language userLanguage = Application.systemLanguage.ToString(); // Gets the language from the user's system //Read the xml file using the dll MyXmlReader MyXmlReader xmlreader = gameObject.AddComponent <MyXmlReader> (); languages = xmlreader.ReadXml(dictonary); // Set initial language SetUserLanguage(); }
/// <summary> /// читает *.xml" файлы /// </summary> private void InitMyXmlReader() { DirectoryInfo directory = new DirectoryInfo(pathDirectoryDictionary); FileInfo[] fileInfos = directory.GetFiles("*.xml"); red = new MyXmlReader(fileInfos); }
public void Temp_Test_For_New_Config_Values_With_Compound_Names() { var xml_reader = new MyXmlReader(); Assert.AreEqual(xml_reader.Read_xml($"{nameof(MainSheetNames)}.{nameof(MainSheetNames.Budget_out)}", _sample_xml_config_file_path), "Budget Out", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(MainSheetNames)}.{nameof(MainSheetNames.Budget_in)}", _sample_xml_config_file_path), "Budget In", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(MainSheetNames)}.{nameof(MainSheetNames.Expected_out)}", _sample_xml_config_file_path), "Expected Out", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(MainSheetNames)}.{nameof(MainSheetNames.Expected_in)}", _sample_xml_config_file_path), "Expected In", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(MainSheetNames)}.{nameof(MainSheetNames.Totals)}", _sample_xml_config_file_path), "Totals", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(MainSheetNames)}.{nameof(MainSheetNames.Savings)}", _sample_xml_config_file_path), "Savings", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(MainSheetNames)}.{nameof(MainSheetNames.Bank_out)}", _sample_xml_config_file_path), "Bank Out", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(MainSheetNames)}.{nameof(MainSheetNames.Bank_in)}", _sample_xml_config_file_path), "Bank In", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(MainSheetNames)}.{nameof(MainSheetNames.Cred_card1)}", _sample_xml_config_file_path), "CredCard1", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(MainSheetNames)}.{nameof(MainSheetNames.Cred_card2)}", _sample_xml_config_file_path), "CredCard2", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(MainSheetNames)}.{nameof(MainSheetNames.Cred_card3)}", _sample_xml_config_file_path), "CredCard3", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(Dividers)}.{nameof(Dividers.Divider_text)}", _sample_xml_config_file_path), "divider", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(Dividers)}.{nameof(Dividers.Expenses)}", _sample_xml_config_file_path), "Expenses", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(Dividers)}.{nameof(Dividers.Expenses_total)}", _sample_xml_config_file_path), "Expenses Total", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(Dividers)}.{nameof(Dividers.Sodds)}", _sample_xml_config_file_path), "SODDs", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(Dividers)}.{nameof(Dividers.Cred_card1)}", _sample_xml_config_file_path), "CredCard1 cred card", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(Dividers)}.{nameof(Dividers.Cred_card2)}", _sample_xml_config_file_path), "CredCard2 cred card", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(Dividers)}.{nameof(Dividers.SODD_total)}", _sample_xml_config_file_path), "SODDTotal", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(Dividers)}.{nameof(Dividers.Annual_sodds)}", _sample_xml_config_file_path), "AnnualSODDs", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(Dividers)}.{nameof(Dividers.Annual_total)}", _sample_xml_config_file_path), "AnnualTotal", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(Dividers)}.{nameof(Dividers.Date)}", _sample_xml_config_file_path), "Date", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(Dividers)}.{nameof(Dividers.Total)}", _sample_xml_config_file_path), "Total", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(PocketMoneySheetNames)}.{nameof(PocketMoneySheetNames.Second_child)}", _sample_xml_config_file_path), "SecondChild", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(PlanningSheetNames)}.{nameof(PlanningSheetNames.Expenses)}", _sample_xml_config_file_path), "Expenses", _sample_xml_config_file_path); Assert.AreEqual(xml_reader.Read_xml($"{nameof(PlanningSheetNames)}.{nameof(PlanningSheetNames.Deposits)}", _sample_xml_config_file_path), "Deposits", _sample_xml_config_file_path); }
public static SyndicationFeed GetFeed(string uri, string timeFormat = "") { if (!string.IsNullOrEmpty(uri)) { var ff = new Rss20FeedFormatter(); // for Atom you can use Atom10FeedFormatter() var xr = new MyXmlReader(uri, timeFormat); ff.ReadFrom(xr); return(ff.Feed); } return(null); }
public void Temp_Test_For_New_Config_Values() { var xml_reader = new MyXmlReader(); Assert.AreEqual(xml_reader.Read_xml($"{nameof(TestSheetNames)}.{nameof(TestSheetNames.Cred_card1)}"), "CredCard1"); Assert.AreEqual(xml_reader.Read_xml($"{nameof(TestSheetNames)}.{nameof(TestSheetNames.Test_record)}"), "TestRecord"); Assert.AreEqual(xml_reader.Read_xml($"{nameof(TestSheetNames)}.{nameof(TestSheetNames.Cred_card)}"), "CredCard"); Assert.AreEqual(xml_reader.Read_xml($"{nameof(TestSheetNames)}.{nameof(TestSheetNames.Bank)}"), "Bank"); Assert.AreEqual(xml_reader.Read_xml($"{nameof(TestSheetNames)}.{nameof(TestSheetNames.Bad_divider)}"), "BadDivider"); Assert.AreEqual(xml_reader.Read_xml($"{nameof(TestSheetNames)}.{nameof(TestSheetNames.Budget_out)}"), "Budget Out"); Assert.AreEqual(xml_reader.Read_xml($"{nameof(TestSheetNames)}.{nameof(TestSheetNames.Expected_out)}"), "Expected Out"); }
public void TestSome() { var list = new List <string>(); using (var reader = new MyXmlReader(new FileStream("testRSS.xml", FileMode.Open))) { SyndicationFeed feed = SyndicationFeed.Load(reader); reader.Close(); foreach (var item in feed.Items) { list.Add(item.Title.Text); } } }
void Awake() { //Read the xml file using the dll MyXmlReader MyXmlReader xmlreader = gameObject.AddComponent <MyXmlReader> (); languages = xmlreader.ReadXml(dictonary); int hint = Random.Range(0, 9); infoText.text = Hints(hint); time = Time.time; waitMinTime = 3f; nextScreen.gameObject.SetActive(false); loadingImag.gameObject.SetActive(true); loadingImag.fillAmount = 0f; source = nextScreen.gameObject.GetComponent <AudioSource> (); }
public Feed GetRemoteFeed(Feed lFeed, int timeout = 0) { string url = lFeed.Url; string siteUrl = lFeed.SiteUrl; var remoteFeed = new Feed { Url = url }; SyndicationFeed rss = null; XmlReader reader = null; var encoding = GetEncoding(url, siteUrl); try { var str = string.Empty; using (var wc = new WebClient()) { remoteFeed.Encoding = encoding; wc.Headers["User-Agent"] = "www.rssheap.com"; wc.Encoding = encoding; str = wc.DownloadString(url); } str = str.Replace("media:thumbnail", "media"); //mashable fix reader = new MyXmlReader(new StringReader(str), new XmlReaderSettings { //MaxCharactersInDocument can be used to control the maximum amount of data //read from the reader and helps prevent OutOfMemoryException MaxCharactersInDocument = 1024 * 64 * 64 * 64, DtdProcessing = DtdProcessing.Parse }); rss = SyndicationFeed.Load(reader); } catch { try { var rss10ff = new Rss10FeedFormatter(); rss10ff.ReadFrom(reader); rss = rss10ff.Feed; } catch { return(null); } } if (rss == null || rss.Items == null) { return(null); } string authorName = (rss.Authors != null && rss.Authors.Count > 0) ? rss.Authors.First().Name ?? rss.Authors.First().Email : string.Empty; remoteFeed.Author = authorName; string title = rss.Title != null ? rss.Title.Text : string.Empty; remoteFeed.Name = title; string description = rss.Description != null ? rss.Description.Text : string.Empty; remoteFeed.Description = description; //get the site url if (rss.Links != null) { var siteLink = rss.Links.FirstOrDefault(l => l.RelationshipType == "alternate"); if (siteLink != null) { try { remoteFeed.SiteUrl = siteLink.Uri.AbsoluteUri; } catch { } } if (remoteFeed.SiteUrl.IsNullOrEmpty() && rss.Links.Count > 0) { try { remoteFeed.SiteUrl = rss.Links.First().Uri.AbsoluteUri; } catch { } } } if (remoteFeed.SiteUrl.IsNullOrEmpty()) { try { remoteFeed.SiteUrl = new Uri(rss.Id).AbsoluteUri; } catch { } } if (remoteFeed.SiteUrl.IsNullOrEmpty() && !siteUrl.IsNullOrEmpty()) { remoteFeed.SiteUrl = siteUrl; //find canonical var html = string.Empty; using (var wc = new WebClient()) { wc.Encoding = encoding; html = wc.DownloadString(siteUrl); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var canonical = htmlDocument.DocumentNode.SelectNodes("//link") .Where(s => s.GetAttributeValue("rel", false) && s.GetAttributeValue("href", false) && s.GetAttributeValue("rel", string.Empty) == "canonical") .Select(s => s.GetAttributeValue("href", string.Empty)) .FirstOrDefault(c => !c.IsNullOrEmpty()); if (!canonical.IsNullOrEmpty()) { if (canonical != "/") { remoteFeed.SiteUrl = canonical; } else { remoteFeed.SiteUrl = siteUrl; } } } } if (remoteFeed.SiteUrl.IsNullOrEmpty()) { try { remoteFeed.SiteUrl = new Uri(url).GetLeftPart(UriPartial.Authority); } catch { } } foreach (var item in rss.Items) { try { var uri = item.Links[0].Uri; string itemUrl = string.Empty; if (uri.IsAbsoluteUri) { if (item.Links.Any(t => t.MediaType.IsNullOrEmpty())) { itemUrl = item.Links.First(t => t.MediaType.IsNullOrEmpty()).Uri.AbsoluteUri; } else { itemUrl = item.Links[0].Uri.AbsoluteUri; } } else { itemUrl = new Uri(new Uri(remoteFeed.SiteUrl), uri.ToString()).AbsoluteUri; } if (itemUrl.IsNullOrEmpty()) { continue; } string itemBody = string.Empty; Article feedItem = new Article(); itemBody = item.Summary != null ? item.Summary.Text : string.Empty; if (item.ElementExtensions != null) { string bodyTemp = item.ElementExtensions .ReadElementExtensions <string>("encoded", "http://purl.org/rss/1.0/modules/content/") .FirstOrDefault(); if (bodyTemp != null) { itemBody = bodyTemp; } } if (itemBody.IsNullOrEmpty()) { if (item.Content != null) { if (item.Content is TextSyndicationContent textContent) { itemBody = textContent.Text; } } } feedItem.Name = item.Title != null ? item.Title.Text : string.Empty; if (feedItem.Name.IsNullOrEmpty()) { feedItem.Name = itemUrl; if (itemUrl.IndexOf("/") > 0) { var lastIndex = itemUrl.LastIndexOf("/") + 1; var strippedUrl = itemUrl.Substring(lastIndex, itemUrl.Length - lastIndex).Replace("-", " "); if (strippedUrl.IndexOf("-") > 0) { feedItem.Name = strippedUrl; } } } if (!feedItem.Name.IsNullOrEmpty()) { feedItem.Name = feedItem.Name.Trim(); } if (item.Authors.Count > 0) { remoteFeed.Author = item.Authors[0].Name ?? item.Authors[0].Email; } feedItem.Url = itemUrl; //if it is feedburner get the url from <feedburner:origLink> var elemExt = item.ElementExtensions.FirstOrDefault(e => e.OuterName == "origLink"); if (elemExt != null) { feedItem.Url = elemExt.GetObject <XElement>().Value; } feedItem.Body = itemBody; feedItem.Published = item.PublishDate.DateTime != DateTime.MinValue ? item.PublishDate.DateTime : item.LastUpdatedTime.DateTime; if (feedItem.Published == DateTime.MinValue) { try { var date = item.ElementExtensions.FirstOrDefault(e => e.OuterName.ToLower().Contains("date")).GetObject <XElement>().Value; feedItem.Published = DateTime.Parse(date); } catch { } } if (feedItem.Published == DateTime.MinValue) { try { var blogPubDate = rss.ElementExtensions.FirstOrDefault(e => e.OuterName.ToLower().Contains("date")).GetObject <XElement>().Value; feedItem.Published = DateTime.Parse(blogPubDate); } catch { if (rss.LastUpdatedTime.Date > DateTime.MinValue) { feedItem.Published = rss.LastUpdatedTime.Date; } } } if (remoteFeed.SiteUrl.Contains("echojs.com") && feedItem.Published == DateTime.MinValue) { feedItem.Published = DateTime.Now; } if (feedItem.Published == DateTime.MinValue && lFeed.Public) { feedItem.Published = DateTime.Now; } remoteFeed.Articles.Add(feedItem); } catch (Exception ex) { new LogService().InsertError(ex.ToString(), "GetRemoteRss FeedUrl: " + url); } } return(remoteFeed); }
public void Can_Read_Path_From_Config() { var xml_reader = new MyXmlReader(); Assert.AreEqual("This value should always be this string.", xml_reader.Read_xml(nameof(ReconConsts.Test_value_do_not_change), _sample_xml_config_file_path)); }
public void Temp_Test_For_New_Config_Values(string element_name, string element_value) { var xml_reader = new MyXmlReader(); Assert.AreEqual(element_value, xml_reader.Read_xml(element_name, _sample_xml_config_file_path)); }
public CustomDisplayName() { this.DisplayName = MyXmlReader.Read(DisplayName); }
public void All_Config_Values_Should_Be_In_Config(string element_name, string element_value) { var xml_reader = new MyXmlReader(); Assert.AreEqual(element_value, xml_reader.Read_xml(element_name, _sample_xml_config_file_path)); }