public override void FromXML(XmlNode node) { // TODO: Implement differently? String[] keys = new String[marketObjectXMLNamesSingle.Keys.Count]; String[] values = new String[marketObjectXMLNamesSingle.Values.Count]; marketObjectXMLNamesSingle.Keys.CopyTo(keys, 0); marketObjectXMLNamesSingle.Values.CopyTo(values, 0); // clear data members _configurations.Clear(); _marketObjects.Clear(); // add default configuration (may be overwritten below) MarketConfiguration defaultConfig = new MarketConfiguration(); AddConfiguration(Market.DefaultConfiguration, defaultConfig); // fill data from XML CheckNode(node, "TodaysMarket"); XmlNode n = GetChildNode(node, ""); while (n != null) { if (GetNodeName(n) == "Configuration") { MarketConfiguration tmp = new MarketConfiguration(); for (int i = 0; i < numberOfMarketObjects; ++i) { tmp.SetId((MarketObject)i, GetChildValue(n, marketObjectXMLNames[i] + "Id", false)); AddConfiguration(GetAttribute(n, "id"), tmp); } } else { int i = 0; for (; i < numberOfMarketObjects; ++i) { if (GetNodeName(n) == marketObjectXMLNames[i]) { string id = GetAttribute(n, "id"); if (id == "") { id = Market.DefaultConfiguration; } // The XML schema for swap indices is different ... if ((MarketObject)i == MarketObject.SwapIndexCurve) { List <XmlNode> nodes = GetChildrenNodes(n, keys[i]); Dictionary <string, string> swapIndices = new Dictionary <string, string>(); foreach (XmlNode xn in nodes) { string name = GetAttribute(xn, values[i]); Utils.QL_REQUIRE(name != "", () => "no name given for SwapIndex"); Utils.QL_REQUIRE(!swapIndices.ContainsKey(name), () => "Duplicate SwapIndex found for " + name); string disc = GetChildValue(xn, "Discounting", true); swapIndices[name] = disc; //.emplace(name, { ibor, disc }); won't work? } AddMarketObject(MarketObject.SwapIndexCurve, id, swapIndices); } else { try { var mp = GetChildrenAttributesAndValues(n, keys[i], values[i], false); int nc = GetChildrenNodes(n, "").Count; Utils.QL_REQUIRE(mp.Count == nc, () => "could not recognise " + (nc - mp.Count) + " sub nodes under " + marketObjectXMLNames[i]); AddMarketObject((MarketObject)i, id, mp); } catch (Exception ex) { var debug = ""; } } break; } } Utils.QL_REQUIRE(i < numberOfMarketObjects, () => "TodaysMarketParameters.FromXML(): node not recognized: " + GetNodeName(n)); } try { n = GetNextSibling(n, ""); } catch (Exception ex) { var debug = ""; } } }
public void AddConfiguration(string id, MarketConfiguration configuration) { _configurations[id] = configuration; }