Esempio n. 1
0
        private void ParseAttribute(string file, out ShxAttributeNode root, out List <ShxAttributeNode> nodes, string prefixNodePath)
        {
            root = new ShxAttributeNode(prefixNodePath);
            root.AttributeFileName = file; // 파일 이름 설정
            nodes = new List <ShxAttributeNode>();

            System.IO.StreamReader stream = new System.IO.StreamReader(file);

            while (true)
            {
                string str = stream.ReadLine();

                if (String.IsNullOrEmpty(str) == true)
                {
                    break;
                }

                if (str.Trim() == "NEW Header Information")
                {
                    continue;
                }
                if (str.Trim().StartsWith("NEW") == false)
                {
                    continue;
                }

                root.ParentNode = null;
                nodes.Add(root);
                root.SetNode(stream, str, nodes);
                break;
            }

            stream.Close();
        }
Esempio n. 2
0
        /// <summary>
        /// 노드 설정
        /// </summary>
        /// <param name="stream">파일 열기 스트림</param>
        /// <param name="node">노드 이름</param>
        /// <param name="nodes">전체 노드 목록</param>
        public void SetNode(System.IO.StreamReader stream, string node, List <ShxAttributeNode> nodes)
        {
            SetName(node);

            while (true)
            {
                string str = stream.ReadLine();

                if (String.IsNullOrEmpty(str) == true)
                {
                    break;
                }

                if (str.Trim().StartsWith("NEW") == true)
                {
                    ShxAttributeNode child = new ShxAttributeNode();
                    child.ParentNode = this;
                    Children.Add(child);
                    nodes.Add(child);
                    child.SetNode(stream, str, nodes);
                }
                else if (str.Trim().StartsWith("END") == true)
                {
                    break;
                }
                else
                {
                    string[] separatingChars = { ":=" };
                    string[] vals            = str.Trim().Split(separatingChars, StringSplitOptions.RemoveEmptyEntries);

                    if (vals != null && vals.Length > 0)
                    {
                        if (Property.ContainsKey(vals[0].Trim()) == false)
                        {
                            Property.Add(vals[0].Trim(), vals.Length == 2 ? vals[1].Trim() : String.Empty);
                        }
                    }
                }
            }
        }