private void SetParamsDict(IList <string> args) { _paramsDict = new Dictionary <string, string>(); for (int i = 0; i < args.Count; i++) { if (ArgIsParameter(args, i) && ArgParameterHasValue(args, i)) { try { string key = ArgAsParameter(args[i]); string val = ArgParameterValue(args, i); ParamsDict.Add(key, val); } catch (Exception) { Console.WriteLine("{0} : -> : {1}", ArgAsParameter(args[i]), ArgParameterHasValue(args, i)); } } else if (ArgIsParameter(args, i)) { try { string key = ArgAsParameter(args[i]); Console.WriteLine("key = " + key); string val = Convert.ToString(true); ParamsDict.Add(key, val); } catch (Exception) { Console.WriteLine("{0} : -> : {1}", ArgAsParameter(args[i]), ArgParameterHasValue(args, i)); } } } }
public String this[string index] { get { if (ParamsDict.ContainsKey(index)) { return(ParamsDict[index]); } else { return(""); } } }
public SideEffectParam(List <SideEffectValue> sevs, int factor = 1) { foreach (SideEffectValue.ValueTypes valueType in Enum.GetValues(typeof(SideEffectValue.ValueTypes))) { ParamsDict.Add(valueType, new Dictionary <string, SideEffectValue>()); } foreach (SideEffectValue sev in sevs) { ParamsDict[sev.ValueType].Add(sev.Name, sev); } Factor = factor; }
private object[,] ReadRangeValues(string paramKey) { string[] vs = paramKey.Split('.'); object[,] paramArray; if (ParamsDict.ContainsKey(paramKey)) { paramArray = ParamsDict[paramKey]; } else { SheetConfigModel sheetConfigModel = SheetConfigModels[vs[0]]; if (vs.Length == 2) { var array = SheetName2ExcelSheet[vs[0]].Range[vs[1] + sheetConfigModel.StartingLine + ":" + vs[1] + sheetConfigModel.EndLine].Value[10]; if (array as object[, ] != null) { paramArray = array; } else { int[] arrParam = { 1, 1 }; paramArray = Array.CreateInstance(typeof(object), arrParam, arrParam) as object[, ]; paramArray[1, 1] = array; } } else { int[] arrParam = { 1, 1 }; paramArray = Array.CreateInstance(typeof(object), arrParam, arrParam) as object[, ]; paramArray[1, 1] = SheetName2ExcelSheet[vs[0]].Range[vs[1] + vs[2]].Value[10]; } ParamsDict[paramKey] = paramArray; } return(paramArray); }
private void ButtonSelectConfigFile_Click(object sender, RoutedEventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog { InitialDirectory = Environment.CurrentDirectory, Filter = "ini 配置文件|*.ini", Multiselect = false, }; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ViewModel.ConfigFilePath = fileDialog.FileName; } ; PushMessage("加载配置文件中。\n"); if (Workbook != null) { Workbook.Save(); Workbook.Close(); SheetName2ExcelSheet.Clear(); SheetConfigModels.Clear(); BodyParams.Clear(); SubjectParams.Clear(); MailToParams.Clear(); OutPutText.Clear(); ParamsDict.Clear(); buttonStart.Click -= ButtonStart_Click; buttonSendTestMail.Click -= ButtonSendTestMail_Click; } bool loadSuccess = LoadConfig(); if (loadSuccess) { buttonStart.Click += ButtonStart_Click; buttonSendTestMail.Click += ButtonSendTestMail_Click; } }
public bool ContainsParam(string name) { return(ParamsDict.ContainsKey(name)); }