/// <summary> /// 解析内容 /// </summary> /// <param name="root"></param> /// <param name="exchange"></param> /// <param name="mgr"></param> internal static void Get(XmlElement root, Exchange exchange, FutureManager mgr) { exchange.ExchangeID = root.GetAttribute(IdAttr); exchange.ExchangeName = root.GetAttribute(NameAttr); XmlText txtNode = null; DateTime dtime = default(DateTime); TimeSpan tsvalue; foreach (XmlNode subNode in root.ChildNodes) { XmlElement subTagNode = subNode as XmlElement; if (subTagNode == null) continue; switch (subTagNode.Name) { case ProductTag: FutureProduct product = new FutureProduct(); product.ExchangeID = exchange.ExchangeID; FutureProductXml.Get(subTagNode, product, mgr); if (product.ProductID != "") mgr.AddProduct(product); break; case SliceTag: txtNode = subTagNode.FirstChild as XmlText; if (txtNode == null || txtNode.Value.Trim() == "") throw new Exception("配置文件格式不对"); string[] strlist = txtNode.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); int icount = strlist.Length / 2; for (int i = 0; i < icount; ++i) { TimeSlice slice = new TimeSlice(); if (!TimeSpan.TryParse(strlist[i * 2], out tsvalue)) { exchange.AllSlice.Clear(); throw new Exception("配置文件格式不对"); } slice.BeginTime = tsvalue; if (!TimeSpan.TryParse(strlist[i * 2 + 1], out tsvalue)) { exchange.AllSlice.Clear(); throw new Exception("配置文件格式不对"); } slice.EndTime = tsvalue; exchange.AllSlice.Add(slice); } break; case OpenTimeTag: txtNode = subTagNode.FirstChild as XmlText; if (txtNode == null || txtNode.Value.Trim() == "") throw new Exception("配置文件格式不对"); if (!DateTime.TryParse(txtNode.Value, out dtime)) throw new Exception("配置文件格式不对"); exchange.OpenTime = dtime; break; case CloseTimeTag: txtNode = subTagNode.FirstChild as XmlText; if (txtNode == null || txtNode.Value.Trim() == "") throw new Exception("配置文件格式不对"); if (!DateTime.TryParse(txtNode.Value, out dtime)) throw new Exception("配置文件格式不对"); exchange.CloseTime = dtime; break; } } }