Exemplo n.º 1
0
        }// Create()

        //
        //
        //
        //
        public static List <IStringifiable> Create(string strigifiedObjects, bool createNodes = false)
        {
            List <IStringifiable> nodeList = null;

            byte[] byteBuffer = ASCIIEncoding.ASCII.GetBytes(strigifiedObjects);
            using (System.IO.MemoryStream stream = new System.IO.MemoryStream(byteBuffer))
            {
                using (StringifiableReader reader = new StringifiableReader(stream))
                {
                    nodeList = reader.ReadToEnd(createNodes);
                    reader.Close();
                }
                stream.Close();
            }
            return(nodeList);
        }
Exemplo n.º 2
0
        }// TryGetAllUserNames()

        //
        //
        //
        //
        //
        //
        #endregion//Public Static Methods



        #region Private Methods
        // *****************************************************************
        // ****                     Private Methods                     ****
        // *****************************************************************
        //
        //
        //
        //
        // ****                  ReadNodesFromFile()                    ****
        /// <summary>
        /// Reads nodes from file associate with fileIndex.
        /// Some nodes (such as FillHubs) are exploded and their components are added to the list.
        /// </summary>
        private List <Node> ReadNodesFromFile(int fileIndex)
        {
            List <Node> nodeList = new List <Node>();

            Misty.Lib.IO.Xml.StringifiableReader   reader   = new Misty.Lib.IO.Xml.StringifiableReader(m_Files.Values[fileIndex]);
            List <Misty.Lib.IO.Xml.IStringifiable> iStrList = reader.ReadToEnd(true);   // Load stringifiable objects in there.

            foreach (IStringifiable istr in iStrList)                                   // loop thru each, storing those of interest.
            {
                Node aNode = (Node)istr;
                if (aNode.Name.Contains("FillHub"))
                {                                                               // We don't add FillHubs directly, but do add some of their elements (BookLifo objects for example).
                    foreach (IStringifiable iStrElement in aNode.GetElements()) // loop thru elements of the FillHub.
                    {
                        Node element = (Node)iStrElement;
                        if (element.Name.Contains("InstrumentMapEntry"))
                        {
                            string         sKey;
                            InstrumentName name;
                            if (element.Attributes.TryGetValue("Key", out sKey) && !m_KeyToName.ContainsKey(sKey) && InstrumentName.TryDeserialize(element.Attributes["Name"], out name))
                            {
                                m_KeyToName.Add(sKey, name);
                            }
                        }
                        else if (element.Name.Contains("BookLifo"))
                        {
                            nodeList.Add(element);
                        }
                    } // next element in FillHub.
                }
                else
                {
                    nodeList.Add(aNode);                                                // add everything else to the list.
                }
            }
            return(nodeList);
        }//ReadNodesFromFile()