private void WriteMatchInfo(StreamWriter writer, MatchInfo matchInfo) { writer.WriteLine("\t\t\t<{0}>", Constant.MatchInfoTag); writer.WriteLine("\t\t\t\t<{0}>{1}</{0}>", Constant.MatchTag, matchInfo.Match); if (!String.IsNullOrEmpty(matchInfo.Event)) { writer.WriteLine("\t\t\t\t<{0}>{1}</{0}>", Constant.EventTag, matchInfo.Event); } writer.WriteLine("\t\t\t\t<{0}>{1}</{0}>", Constant.SelectionTag, matchInfo.Selection); writer.WriteLine("\t\t\t\t<{0}>{1:F}</{0}>", Constant.KoefficientTag, matchInfo.Koefficient); writer.WriteLine("\t\t\t\t<{0}>{1}</{0}>", Constant.ResultTag, BetResultEx.ToString(matchInfo.Result)); writer.WriteLine("\t\t\t</{0}>", Constant.MatchInfoTag); }
private MatchInfo ParseMatchInfo(XmlNode node) { var builder = MatchInfo.With(); foreach (XmlNode child in node.ChildNodes) { string text = child.InnerText; switch (child.Name) { case Constant.MatchTag: builder.Match(text); break; case Constant.EventTag: builder.Event(text); break; case Constant.KoefficientTag: builder.Koefficient(Converter.ToDecimal(text)); break; case Constant.SelectionTag: builder.Selection(text); break; case Constant.ResultTag: BetResult betRes; if (BetResultEx.TryParse(text, out betRes)) { builder.Result(betRes); } else { throw new InvalidOperationException(String.Format("Cann't parse betResult: {0}", text)); } break; default: break; } } return(builder.Build()); }