private static List <CustomShellType.FuncCode> ReadFuncCodeSettingNode(XmlNode child) { List <CustomShellType.FuncCode> funcCodeList = new List <CustomShellType.FuncCode>(); foreach (XmlNode c in child.ChildNodes) { if (c.Name == "func") { CustomShellType.FuncCode funcCode = new CustomShellType.FuncCode(); //初始化一下Parmas funcCode.FuncParams = new List <CustomShellType.ParamStruct>(); foreach (XmlNode cc in c.ChildNodes) { if (cc.Name == "name") { funcCode.Name = cc.InnerText; } else if (cc.Name == "type") { funcCode.Type = cc.InnerText; } else if (cc.Name == "path") { funcCode.Path = cc.InnerText; } else if (cc.Name == "item") { funcCode.Item = cc.InnerText; } else if (cc.Name == "funcParam") { funcCode.FuncParams.Add(ReadParamNode(cc)); } } funcCodeList.Add(funcCode); } } return(funcCodeList); }
/// <summary> /// 保存funccode /// </summary> private void SaveFuncCodeToListView() { string name = cb_Name.Text.Trim(); string code = tb_FuncCode.Text.Trim(); string location = cb_ParmaLocation.Text.Trim(); string encry = cb_ParmaEncry.Text.Trim(); //检查name字段是否已经存在 if (lv_Func.Items.ContainsKey(name)) { MessageBox.Show("在列表中已存在这个Name"); return; } //检查code,location,encry字段是否为空 if (code == "" || location == "" || encry == "") { MessageBox.Show("code,location,encry字段不许为空"); return; } //检查encry字段的正确性 EncryMode encryMode; try { encryMode = (EncryMode)Enum.Parse(typeof(EncryMode), encry); } catch { MessageBox.Show("encry字段不匹配"); return; } //全部通过检查,则保存 CustomShellType.FuncCode funcCode = new CustomShellType.FuncCode(); funcCode.Name = name; funcCode.Item = code; //funcCode.FuncParmaLocation = location; //funcCode.FuncParmaEncryMode = encryMode; ListViewItem item = new ListViewItem(name); item.Name = name;//检查是否存在,为此赋值作为key item.Tag = funcCode; //绑定funcode到tag lv_Func.Items.Add(item); }
private static List<CustomShellType.FuncCode> ReadFuncCodeSettingNode(XmlNode child) { List<CustomShellType.FuncCode> funcCodeList = new List<CustomShellType.FuncCode>(); foreach (XmlNode c in child.ChildNodes) { if (c.Name == "func") { CustomShellType.FuncCode funcCode = new CustomShellType.FuncCode(); //初始化一下Parmas funcCode.FuncParams = new List<CustomShellType.ParamStruct>(); foreach (XmlNode cc in c.ChildNodes) { if (cc.Name == "name") { funcCode.Name = cc.InnerText; } else if (cc.Name == "type") { funcCode.Type = cc.InnerText; } else if (cc.Name == "path") { funcCode.Path = cc.InnerText; } else if (cc.Name == "item") { funcCode.Item = cc.InnerText; } else if (cc.Name == "funcParam") { funcCode.FuncParams.Add(ReadParamNode(cc)); } } funcCodeList.Add(funcCode); } } return funcCodeList; }
private Dictionary <string, string> GetCode(CustomShellType customShellType, string pass, CustomShellType.FuncCode funcCode, string[] parmas) { DataCombine dataCombine = new DataCombine(); Dictionary <string, string> dic = new Dictionary <string, string>(); //MainCodeSetting string mainCodeString = FillParams(customShellType.MainCodeSetting.Item, customShellType.MainCodeSetting.FuncCodeParam); NameValueCollection mainCodeItem = new NameValueCollection { { pass, EncryItem(customShellType.BasicSetting.MainCodeParam.EncryMode, mainCodeString) } }; AddItemToDic(dic, customShellType.BasicSetting.MainCodeParam.Location, dataCombine.CombineToStr(mainCodeItem)); //FuncCode string funcCodeString = ""; if (funcCode.FuncParams.Count > 0) { funcCodeString = FillParams(funcCode.Item, funcCode.FuncParams); } else { funcCodeString = funcCode.Item; } //判断是否随机参数 string funcParamName = customShellType.MainCodeSetting.FuncCodeParam.Name; if (GlobalSetting.IsParamRandom) { string newguid = _randomParam[funcParamName]; funcParamName = newguid; } NameValueCollection funcCodeItem = new NameValueCollection { { funcParamName, EncryItem(customShellType.MainCodeSetting.FuncCodeParam.EncryMode, funcCodeString) } }; AddItemToDic(dic, customShellType.MainCodeSetting.FuncCodeParam.Location, dataCombine.CombineToStr(funcCodeItem)); //FunParma if (parmas != null && parmas.Length > 0) { if (parmas.Length != funcCode.FuncParams.Count) { throw new Exception("调用方法的参数个数与实现代码的参数个数不符合"); } for (int i = 0; i < parmas.Length; i++) { string parName = funcCode.FuncParams[i].Name; if (GlobalSetting.IsParamRandom) { string newguid = _randomParam[parName]; parName = newguid; } NameValueCollection item = new NameValueCollection { { parName, EncryItem(funcCode.FuncParams[i].EncryMode, parmas[i]) } }; AddItemToDic(dic, funcCode.FuncParams[i].Location, dataCombine.CombineToStr(item)); //dataCombine.AddFuncParmaItem("z" + (i + 1), EncryItem(FuncCode.FuncParmaEncryMode, parmas[i])); } //AddItemToDic(dic, FuncCode.FuncParmaLocation, dataCombine.CombineToStr(dataCombine.FuncParmaItems)); } return(dic); }