예제 #1
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc;
            XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);
            NowLoading = this;
            try
            {
                _color = ValueParser.StringToColor(XmlGetter.Attribute(rootNode, "Color"));
            }
            catch
            {
                _color = Color.Black;
            }
            for (int i = 0; i < rootNode.ChildNodes.Count; i++)
            {
                XmlNode child = rootNode.ChildNodes[i];

                if (child.Name.Equals("String"))
                {
                    _formatItems.Add(new FormatItem(FormatItem.FormatItemType.String, child.InnerText));
                }
                else if (child.Name.Equals("FieldItem"))
                {
                    String parser = XmlGetter.Attribute(child, "Parser");
                    if (parser.Length > 0)
                    {
                        string[] args = ValueParser.GetArgs(parser, XmlGetter.Attribute(child, "Args"));
                        _formatItems.Add(new FormatItem(FormatItem.FormatItemType.FieldItem, args));
                    }
                    else
                    {
                        _formatItems.Add(new FormatItem(FormatItem.FormatItemType.FieldItem));
                    }
                }
            }
        }
예제 #2
0
        public virtual void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            _xDoc = xDoc;  XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            _sendingParser = XmlGetter.Attribute(rootNode, "SendingParser");

            _args = ValueParser.getArgs(XmlGetter.Attribute(rootNode, "Args"));

            _format = new XmlMatchFormat(); //초기값.
            foreach (XmlNode child in rootNode.ChildNodes)
            {
                if (child.Name.Equals("Format"))
                {
                    XmlNode xFormat = child;
                    _format = new XmlMatchFormat();
                    if (xFormat != null)
                    {
                        _format.LoadXml(xDoc, xFormat, refLoad);
                    }
                }
                else
                {
                    String comName    = child.Name;
                    string recentName = null;
                    if (_recentTarget.ContainsKey(comName))
                    {
                        recentName = _recentTarget[comName];
                    }

                    if (comName.Equals("ScenarioTable"))
                    {
                        String targetName = XmlGetter.Attribute(child, "TargetName");
                        if (targetName.Length == 0)
                        {
                            if (recentName != null)
                            {
                                targetName = recentName;
                            }
                            else
                            {
                                throw new Exception("ScenarioTable 을 위한 TargetName이 정의되지 않았습니다.");
                            }
                        }

                        IXmlComponent com = XmlControlHandler.GetComponentByName(targetName); //같은 타입에서는 여러번 TargetName을 쓰지 않아도 인식하도록..

                        if (com != null)
                        {
                            XmlScenarioTable table = com as XmlScenarioTable;
                            if (table != null)
                            {
                                if (targetName.Length > 0)
                                {
                                    _recentTarget[comName] = targetName;//모든 속성이 맞으면 등록..
                                }
                                XmlTableMatchInfo info = new XmlTableMatchInfo(targetName, table);
                                info.LoadXml(xDoc, child);
                                _matchInfoItems.Add(info);
                                _targetComponents.Add(com);

                                String column = XmlGetter.Attribute(child, "ColumnName");
                                if (column.Length > 0)
                                {
                                    if (table.ColumnNames.Contains(column))
                                    {
                                        table.Columns(column).RelativeObject["XmlMatchData"] = XmlMatchData.NowLoading;
                                    }
                                    else
                                    {
                                        throw new Exception("XmlMatchComponent: Table[" + table.Name + "]에 Column[" + column + "] 이 없습니다.");
                                    }
                                }
                            }
                            else
                            {
                                throw new Exception("targetName [" + targetName + "]은 ScenarioTable 이 아닙니다.");
                            }
                        }
                        else
                        {
                            throw new Exception("TargetName [" + targetName + "] 은 배치되지 않았습니다.");
                        }
                    }
                }
            }
        }