protected override YahooManaged.Base.DownloadCompletedEventArgs <MarketResult> ConvertDownloadCompletedEventArgs(YahooManaged.Base.DefaultDownloadCompletedEventArgs <MarketResult> e) { MarketDownloadSettings set = (MarketDownloadSettings)e.Settings; if (set.Sectors != null) { SectorsDownloadCompletedEventArgs args = new SectorsDownloadCompletedEventArgs(e.UserArgs, (SectorResponse)e.Response, set); if (AsyncSectorsDownloadCompleted != null) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(this); asyncOp.Post(new SendOrPostCallback(delegate(object obj) { AsyncSectorsDownloadCompleted(this, (SectorsDownloadCompletedEventArgs)obj); }), args); } return(args); } else if (set.Industries != null) { IndustryDownloadCompletedEventArgs args = new IndustryDownloadCompletedEventArgs(e.UserArgs, (IndustryResponse)e.Response, set); if (AsyncIndustriesDownloadCompleted != null) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(this); asyncOp.Post(new SendOrPostCallback(delegate(object obj) { AsyncIndustriesDownloadCompleted(this, (IndustryDownloadCompletedEventArgs)obj); }), args); } return(args); } else { return(null); } }
public override object Clone() { MarketDownloadSettings cln = new MarketDownloadSettings(); if (this.Sectors != null) { cln.Sectors = this.Sectors; } if (this.Industries != null) { cln.Industries = this.Industries; } return(cln); }
/// <summary> /// Default constructor /// </summary> /// <remarks></remarks> public MarketDownload() { this.Settings = new MarketDownloadSettings(); }
internal IndustryDownloadCompletedEventArgs(object userArgs, IndustryResponse resp, MarketDownloadSettings settings) : base(userArgs, resp, settings) { }
internal SectorsDownloadCompletedEventArgs(object userArgs, SectorResponse resp, MarketDownloadSettings settings) : base(userArgs, resp, settings) { }
protected override MarketResult ConvertResult(YahooManaged.Base.ConnectionInfo connInfo, System.IO.Stream stream, YahooManaged.Base.SettingsBase settings) { MarketDownloadSettings set = (MarketDownloadSettings)settings; if (set.Sectors != null) { List <SectorData> sectors = new List <SectorData>(); System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US"); XDocument doc = MyHelper.ParseXmlDocument(stream); XElement[] results = XPath.GetElements("//sector", doc); foreach (XElement node in results) { System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.CurrentCulture; if (culture != null) { ci = culture; } SectorData sect = new SectorData(); string nameAtt = MyHelper.GetXmlAttributeValue(node, FinanceHelper.NameMarketName); if (nameAtt != string.Empty) { for (Sector s = 0; s <= Sector.Utilities; s++) { if (s.ToString().Replace("_", " ") == nameAtt) { sect.ID = s; break; // TODO: might not be correct. Was : Exit For } } } foreach (XElement industryNode in node.Elements()) { if (industryNode.Name.LocalName == "industry") { IndustryData ind = new IndustryData(); foreach (XAttribute att in industryNode.Attributes()) { if (att.Name.LocalName == FinanceHelper.NameIndustryID) { int i = 0; int.TryParse(att.Value, out i); if (i != 0) { ind.ID = (Industry)i; } } else if (att.Name.LocalName == FinanceHelper.NameMarketName) { ind.Name = att.Value; } } sect.Industries.Add(ind); } } sectors.Add(sect); } return(new SectorResult(sectors.ToArray())); } else if (set.Industries != null) { List <IndustryData> industries = new List <IndustryData>(); System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US"); XDocument doc = MyHelper.ParseXmlDocument(stream); XElement[] results = XPath.GetElements("//industry", doc); foreach (XElement node in results) { IndustryData ind = new IndustryData(); foreach (XAttribute att in node.Attributes()) { if (att.Name.LocalName == FinanceHelper.NameIndustryID) { int i = 0; int.TryParse(att.Value, out i); if (i != 0) { ind.ID = (Industry)i; } } else if (att.Name.LocalName == FinanceHelper.NameMarketName) { ind.Name = att.Value; } } foreach (XElement companyNode in node.Elements()) { if (companyNode.Name.LocalName == "company") { CompanyInfoData comp = new CompanyInfoData(); foreach (XAttribute att in companyNode.Attributes()) { if (att.Name.LocalName == FinanceHelper.NameCompanySymbol) { comp.SetID(att.Value); } else if (att.Name.LocalName == FinanceHelper.NameMarketName) { comp.Name = att.Value; } } ind.Companies.Add(comp); } } industries.Add(ind); } return(new IndustryResult(industries.ToArray())); } else { return(null); } }
public void DownloadAsync(MarketDownloadSettings settings, object userArgs) { base.DownloadAsync(settings, userArgs); }