コード例 #1
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Parses the FpML document extracting the trades.
        /// <para>
        /// This parses the specified FpML root element, using the map of references.
        /// The FpML specification uses references to link one part of the XML to another.
        /// For example, if one part of the XML has {@code <foo id="fooId">}, the references
        /// map will contain an entry mapping "fooId" to the parsed element {@code <foo>}.
        ///
        /// </para>
        /// </summary>
        /// <param name="fpmlRootEl">  the source of the FpML XML document </param>
        /// <param name="references">  the map of id/href to referenced element </param>
        /// <returns> the parsed trades </returns>
        /// <exception cref="RuntimeException"> if a parse error occurred </exception>
        public IList <Trade> parseTrades(XmlElement fpmlRootEl, IDictionary <string, XmlElement> references)
        {
            FpmlDocument       document = new FpmlDocument(fpmlRootEl, references, ourPartySelector, tradeInfoParser, refData);
            IList <XmlElement> tradeEls = document.FpmlRoot.getChildren("trade");

            ImmutableList.Builder <Trade> builder = ImmutableList.builder();
            foreach (XmlElement tradeEl in tradeEls)
            {
                builder.add(parseTrade(document, tradeEl));
            }
            return(builder.build());
        }
コード例 #2
0
        // parses one trade element
        private Trade parseTrade(FpmlDocument document, XmlElement tradeEl)
        {
            // find which trade type it is by comparing children to known parsers
            foreach (KeyValuePair <string, FpmlParserPlugin> entry in tradeParsers.SetOfKeyValuePairs())
            {
                Optional <XmlElement> productOptEl = tradeEl.findChild(entry.Key);
                if (productOptEl.Present)
                {
                    return(entry.Value.parseTrade(document, tradeEl));
                }
            }
            // failed to find a known trade type
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            ImmutableSet <string> childNames = tradeEl.Children.Select(XmlElement::getName).collect(toImmutableSet());

            throw new FpmlParseException("Unknown product type: " + childNames);
        }