示例#1
0
 private static Dictionary<string, IFXCmd> GetFXCommands(XmlNode attributeNode)
 {
     Dictionary<string, IFXCmd> cmdList = new Dictionary<string, IFXCmd>();
     XmlNodeList basicCmdNodeList = attributeNode.SelectSingleNode("BasicCmdList").ChildNodes;                       //获得基本指令集
     foreach (XmlNode basicCmdNode in basicCmdNodeList)
     {
         if (basicCmdNode.NodeType == XmlNodeType.Element)
         {
             FXBasicCmd basicCmd = new FXBasicCmd();
             basicCmd.Name = basicCmdNode.Attributes["name"].Value;
             basicCmd.Comment = basicCmdNode.Attributes["comment"].Value;
             XmlNodeList characterNodeList = basicCmdNode.ChildNodes;
             foreach (XmlNode characterNode in characterNodeList)
             {
                 if (characterNode.NodeType == XmlNodeType.Element)
                 {
                     FXBasicCmdCharacter character = new FXBasicCmdCharacter();
                     character.BasicCmdType = (FXBasicCmdType)Convert.ToInt32(characterNode.Attributes["type"].Value);
                     character.Value = characterNode.Attributes["value"].Value;
                     character.Cmd = basicCmd.Name;
                     if (characterNode.Attributes["adapterType"] != null)
                         character.AdapterType = (FXBasicCmdAdapterType)Convert.ToInt32(characterNode.Attributes["adapterType"].Value);
                     else
                         character.AdapterType = FXBasicCmdAdapterType.NULL;
                     if (characterNode.Attributes["adapter"] != null)
                         character.Adapter = characterNode.Attributes["adapter"].Value;
                     if (characterNode.Attributes["min"] != null)
                         character.Min = Convert.ToInt32(characterNode.Attributes["min"].Value);
                     if (characterNode.Attributes["max"] != null)
                         character.Max = Convert.ToInt32(characterNode.Attributes["max"].Value);
                     basicCmd.Characters.Add(character);
                 }
             }
             cmdList.Add(basicCmd.Name, basicCmd);
         }
     }
     XmlNodeList appCmdNodeList = attributeNode.SelectSingleNode("AppCmdList").ChildNodes;       //获得应用指令集
     foreach (XmlNode appCmdNode in appCmdNodeList)
     {
         if (appCmdNode.NodeType == XmlNodeType.Element)
         {
             FXAppCmd appCmd = new FXAppCmd();
             appCmd.AppCmdType = FXAppCmdType.Normal;
             appCmd.Comment = appCmdNode.Attributes["comment"].Value;
             appCmd.FuncNO = Convert.ToInt32(appCmdNode.Attributes["funcNO"].Value);
             appCmd.Name = appCmdNode.Attributes["name"].Value;
             appCmd.Group = appCmdNode.Attributes["group"].Value;
             cmdList.Add(appCmd.Name, appCmd);
         }
     }
     return cmdList;
 }
示例#2
0
文件: FXComplier.cs 项目: cubean/CG
 private static FXBasicCmdCharacter GetBasicCmdCharacter(FXBasicCmd cmd, string[] paramNameArray)
 {
     if (cmd.Characters.Count == 1)              //如果只有一个Character,那么不用遍历了,直接返回
         return cmd.Characters[0];
     foreach (FXBasicCmdCharacter character in cmd.Characters)         //遍历这个命令下的所有Character
     {
         if (character.BasicCmdType == FXBasicCmdType.Single || character.BasicCmdType == FXBasicCmdType.Double)
         {
             if (paramNameArray.Length == 1)
             {
                 bool isFit = IsParamFitAdapter(character, paramNameArray);
                 if (isFit)
                     return character;
             }
         }
         if (character.BasicCmdType == FXBasicCmdType.Triple || character.BasicCmdType == FXBasicCmdType.Five)
         {
             bool isFit = IsParamFitAdapter(character, paramNameArray);
             if (isFit)
                 return character;
         }
     }
     throw new Exception("can not find character that meet the param. At " + FXComplier.m_nowProcessLine.BasicLineStr);
 }