Beispiel #1
0
        public XmlTemplate Clone()
        {
            XmlTemplate template = new XmlTemplate(_fullPath);

            if (_command != null)
            {
                template._command = _command.Clone();
            }
            if (_response != null)
            {
                template._response = _response.Clone();
            }
            if (_autoResponse != null)
            {
                template._autoResponse = _autoResponse.Clone();
            }
            template._info = _info;//info는 공용으로 써도 된다.
            return(template);
        }
Beispiel #2
0
        //ListDic<String, XmlCommand> _packetList = new ListDic<string, XmlCommand>();
        //public ListDic<String, XmlCommand> PacketList { get { return _packetList; } }

        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null) return;
            XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            XmlNode info = XmlGetter.Child(rootNode, Properties.Resources.Scenario_InfoNodeName);
            _info.LoadXml(_xDoc, info);
            
            if(refLoad==false) _itemList.Clear();//초기화
            
            XmlNode xScenItemList = XmlGetter.Child(rootNode, Properties.Resources.Scenario_CommandListNodeName);
            int packetCount = 0;
            int scenCount = 0;
            foreach (XmlNode xScenItem in xScenItemList.ChildNodes)
            {

                if (xScenItem.Name.Equals(Properties.Resources.Scenario_ItemName_ScenarioNodeName))//"Scenario"))
                {
                    scenCount++;
                    XmlScenario scen = new XmlScenario();
                    scen.LoadXml(_xDoc, xScenItem);
                    _itemList.Add(scen);
                }
                else if (xScenItem.Name.Equals(Properties.Resources.Scenario_ItemName_CommandGroupNodeName))//"CommandGroup"))
                {
                    packetCount++;
                    String name = XmlGetter.Attribute(xScenItem, "Name");
                    if (name.Length == 0) throw new Exception("시나리오파일 [" + NowLoadingFile + "]," + packetCount + "번째 Packet 태그에 Name속성이 없습니다.");

                    String template = XmlGetter.Attribute(xScenItem, "Template");
                    if (template.Contains("."))
                    {
                        template = template.Substring(template.LastIndexOf(".")+1);//.의 가장 맨 뒤의 이름만 가져옴..
                    }
                    if (template.Length == 0) throw new Exception("시나리오파일 [" + NowLoadingFile + "]," + packetCount + "번째 Packet 태그(Name=" + name + ")에 Template속성이 없습니다.");

                    XmlTemplate xTemplate = TemplateInfos.This.GetTemplate(template);//._totalTemplates[template];

                    XmlCommand packet = new XmlCommand(name, xTemplate, this);
                    packet.LoadXml(_xDoc, xScenItem);
                    _itemList.Add(packet);
                }
                else if (xScenItem.Name.Equals("Command"))
                {
                    packetCount++;
                    String name = XmlGetter.Attribute(xScenItem, "Name");
                    if (name.Length == 0) throw new Exception("시나리오파일 [" + NowLoadingFile + "]," + packetCount + "번째 Packet 태그에 Name속성이 없습니다.");

                    String template = XmlGetter.Attribute(xScenItem, "Template");
                    if (template.Length == 0) throw new Exception("시나리오파일 [" + NowLoadingFile + "]," + packetCount + "번째 Packet 태그(Name=" + name + ")에 Template속성이 없습니다.");
                    if (template.Contains("."))
                    {
                        template = template.Substring(template.LastIndexOf(".") + 1);
                    }
                    XmlTemplate xTemplate;
                    if ((xTemplate = TemplateInfos.This.GetTemplate(template))!=null)
                    {
                        
                        XmlCommand packet = new XmlCommand(name, xTemplate, this);
                        try
                        {
                            packet.LoadXml(_xDoc, xScenItem);
                        }
                        catch (Exception e)
                        {
                            throw new Exception("Error on Loading Command [" + packet.Name + "]\r\n"+e.Message);
                        }
                        _itemList.Add(packet);
                    }
                    else
                    {
                        throw new Exception("Template " + template + " doesn't exist which should be in Scenario File[" + _filePath + "]");
                    }
                    
                }
            }

        }
Beispiel #3
0
 public XmlCommand(String name, XmlTemplate xmlTemplate, XmlScenario parentScenario)
 {
     _name           = name;
     _template       = xmlTemplate.Clone();
     _parentScenario = parentScenario;
 }