Esempio n. 1
0
        /// <summary>
        /// Creates Xml Element from strings
        /// </summary>
        /// <param name="text">The strings</param>
        /// <param name="bRow">The begin row</param>
        /// <param name="bColumn">The begin column</param>
        /// <param name="eRow">The end row</param>
        /// <param name="eColumn">The end column</param>
        /// <returns>Created Xml Element</returns>
        protected override XElement[] CreateElements(IList <string> text, int bRow, int bColumn, int eRow, int eColumn)
        {
            int bb = bRow;
            int bc = bColumn;
            int brf;
            int bcf;
            IXmlElementCreator creator = this;
            List <XElement>    l       = new List <XElement>();

            while (true)
            {
                try
                {
                    FindNext(text, bb, bc, out brf, out bcf);
                    XElement e = creator.Create(text, bb, bc, brf, bcf);
                    if (e == null)
                    {
                        break;
                    }
                    l.Add(e);
                    StaticExtensionXmlParserLibrary.FindNext(text, openString, true, brf, bcf, out bb, out bc);
                }
                catch (Exception ex)
                {
                    ex.ShowError(10);
                    break;
                }
            }
            return(l.ToArray());
        }
Esempio n. 2
0
        /// <summary>
        /// Creates Xml Element from strings
        /// </summary>
        /// <param name="text">The strings</param>
        /// <param name="bRow">The begin row</param>
        /// <param name="bColumn">The begin column</param>
        /// <param name="eRow">The end row</param>
        /// <param name="eColumn">The end column</param>
        /// <returns>Created Xml Element</returns>
        protected override XElement CreateInternal(IList <string> text, int bRow, int bColumn, int eRow, int eColumn)
        {
            List <int> l = null;

            if (dic.ContainsKey(bRow))
            {
                l = dic[bRow];
            }
            else
            {
                l         = new List <int>();
                dic[bRow] = l;
            }
            if (l.Contains(eRow))
            {
                return(null);
            }
            l.Add(eRow);
            int      bbRow    = bRow;
            int      bbColumn = bColumn;
            int      eeRow;
            int      eeColumn;
            XElement element = creator.Create(text, bRow, bColumn, eRow, eColumn);

            if (element == null)
            {
                return(null);
            }
            while (true)
            {
                string s = StaticExtensionXmlParserLibrary.FindNext(text, openString, false, bbRow, bbColumn, out eeRow, out eeColumn);
                if (s == null)
                {
                    return(element);
                }
                if (eeRow >= eRow)
                {
                    break;
                }
                bbRow    = eeRow;
                bbColumn = eeColumn;
                FindNextClose(text, openString, closeString, true, bbRow, bbColumn, out eeRow, out eeColumn);
                XElement e = This.Create(text, bbRow, bbColumn, eeRow, eeColumn);
                if (e != null)
                {
                    element.Add(e);
                }
                bbRow     = eeRow;
                bbColumn  = eeColumn;
                endRow    = eeRow;
                endColumn = eeColumn;
            }
            return(element);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates document from list of strings
        /// </summary>
        /// <param name="text">List of strings</param>
        /// <returns>The document</returns>
        public static XElement Create(IList <string> text)
        {
            XElement doc = XElement.Parse("<Root/>");

            int nr = text.Count - 1;
            int nc = text[nr].Length;

            --nc;
            int eRow;
            int eColumn;

            SimulinkXmlParser  parser  = new SimulinkXmlParser(doc);
            IXmlElementCreator creator = parser;

            StaticExtensionXmlParserLibrary.FindNext(text, '{', false, 0, 0, out eRow, out eColumn);
            XElement[] elements = parser.Create(text, eRow, eColumn, nr, nc);
            foreach (XElement e in elements)
            {
                doc.Add(e);
            }
            return(parser.doc);
        }