EnginneModel.cs
namespace WindowsFormsApp3 { public class EnginneModel { public string paramsName { get; set; } public string paramsType { get; set; } public string paramsBindingData { get; set; } } }
EnginneDAL.cs
namespace WindowsFormsApp3 { public class EnginneDAL { public List<EnginneModel> InPara = new List<EnginneModel>(); public List<EnginneModel> OutPara = new List<EnginneModel>(); } }
EnginneTool.cs
namespace WindowsFormsApp3 { public class EnginneTool { EnginneDAL enginneDAL = new EnginneDAL(); public void SaveData(List<string> listIn, List<string> listOut) { for (int i = 0; i < listIn.Count/3; i++) { EnginneModel enginneModel = new EnginneModel(); enginneModel.paramsName = (listIn[i*3]); enginneModel.paramsType = (listIn[i*3+1]); enginneModel.paramsBindingData = (listIn[i*3+2]); enginneDAL.InPara.Add(enginneModel); } for (int i = 0; i < listOut.Count / 3; i++) { EnginneModel enginneModel = new EnginneModel(); enginneModel.paramsName = (listOut[i * 3]); enginneModel.paramsType = (listOut[i * 3 + 1]); enginneModel.paramsBindingData = (listOut[i * 3 + 2]); enginneDAL.OutPara.Add(enginneModel); } } public void Run(EnginneDAL enginneDAL) { string s= enginneDAL.InPara[0].paramsBindingData; enginneDAL.OutPara[0].paramsName = s; } } }
解析tree view函数
/// <summary> /// 解析treeview数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { List<string> ListInpara = new List<string>(); List<string> ListOutPara = new List<string>(); List<string> ListIn = new List<string>(); List<string> ListOut = new List<string>(); ListInpara.Add("(Image)image:工具1-OutImage"); ListInpara.Add("(Parameter)Max:工具2-InPara1"); ListOutPara.Add("(Parameter)Area:工具2-OutPara1"); TreeviewNameSplit(ListInpara, ref ListIn); TreeviewNameSplit(ListOutPara, ref ListOut); EnginneTool enginneTool = new EnginneTool(); enginneTool.SaveData(ListIn, ListOut); } /// <summary> /// 解析方法 /// </summary> /// <param name="list"></param> /// <param name="listPara"></param> public void TreeviewNameSplit(List<string> list, ref List<string> listPara) { foreach (var item in list) { string ss = item.Replace("(", ""); string[] sType = ss.Split(')'); listPara.Add(sType[0]); foreach (var item1 in sType) { if (item1.Contains(":")) { string[] sName = item1.Split(':'); listPara.Add(sName[0]); listPara.Add(sName[1]); } } } }
标签:string,C#,tree,TOOl,List,enginneModel,Add,new,public From: https://www.cnblogs.com/xiaohuzi007/p/16860320.html