private void LoadTargetTasks(ProjectTargetElement target, List<EnvVar> vars, BuildToolDefine tool, ToolOptions toolOptions, params List<ToolFlag>[] commonFlags) { foreach (ProjectTaskElement task in target.Tasks) { BuildScript script = new BuildScript(); string exeCmdEnv = ToEnvVar(tool.Description.ToLower()).Trim(); string exeCmd = tool.Description.ToLower(); int idx = -1; script.Conditional = task.Condition; script.Script = task.GetParameter(TaskScriptAttributeName); if (!string.IsNullOrEmpty(script.Script)) { if ((idx = script.Script.ToLower().IndexOf(exeCmdEnv)) >= 0) { // remove exe command and script.Script = script.Script.Remove(idx, exeCmdEnv.Length); script.Script = RemoveFlagsAndWrapper(script.Script, toolOptions, commonFlags); toolOptions.BuildToolParameters.Parameters.Add(script); } else if ((idx = script.Script.ToLower().IndexOf(exeCmd)) >= 0) { // remove exe command and script.Script = script.Script.Remove(idx, exeCmd.Length); script.Script = RemoveFlagsAndWrapper(script.Script, toolOptions, commonFlags); toolOptions.BuildToolParameters.Parameters.Add(script); } else if (toolOptions.BuildToolParameters.Parameters.Count > 0) { toolOptions.BuildToolParameters.PostBuild.Add(script); } else { toolOptions.BuildToolParameters.PreBuild.Add(script); } } else if(string.Compare(task.Name, SetEnvScriptTag) == 0) { EnvVar var = new EnvVar(); var.Name = task.GetParameter("Name"); var.Conditional = task.Condition; var.Value = task.GetParameter("Value"); vars.Add(var); } } }
void SaveGridView() { dataGridView.EndEdit(); if (dataGridView.Tag is EnvVars) { List<EnvVar> evc = (dataGridView.Tag as EnvVars).EnvVarCollection; evc.Clear(); foreach (DataGridViewRow row in dataGridView.Rows) { if (row.Cells[0].Value != null) { EnvVar env = new EnvVar(); env.Name = row.Cells[0].Value.ToString(); env.Value = (row.Cells[1].Value == null ? "" : row.Cells[1].Value.ToString()); env.Conditional = row.Cells[2].Value == null? "" : row.Cells[2].Value.ToString(); evc.Add(env); } } } else if (dataGridView.Tag is List<ToolFlag>) { List<ToolFlag> flags = (dataGridView.Tag as List<ToolFlag>); flags.Clear(); foreach (DataGridViewRow row in dataGridView.Rows) { if (row.Cells[0].Value != null || row.Cells[1].Value != null) { ToolFlag flag = new ToolFlag(); flag.Conditional = (row.Cells[0].Value == null ? "" : row.Cells[0].Value.ToString()); flag.Flag = (row.Cells[1].Value == null ? "" : row.Cells[1].Value.ToString()); flags.Add(flag); } } } else if (dataGridView.Tag is List<BuildParameter>) { List<BuildParameter> parms = (dataGridView.Tag as List<BuildParameter>); parms.Clear(); foreach (DataGridViewRow row in dataGridView.Rows) { if (row.Cells[0].Value != null && row.Cells[1].Value != null) { BuildParameter parm = new BuildParameter(); parm.Parameter = (string)row.Cells[0].Value; parm.Action = (string)row.Cells[1].Value; parm.Description = (string)row.Cells[2].Value; parms.Add(parm); } } } else if (dataGridView.Tag is List<MemorySymbol>) { List<MemorySymbol> msc = dataGridView.Tag as List<MemorySymbol>; msc.Clear(); foreach (DataGridViewRow row in dataGridView.Rows) { if (row.Cells[0].Value != null && row.Cells[1].Value != null) { MemorySymbol parm = new MemorySymbol(); parm.Name = (string)row.Cells[0].Value; parm.Options = (string)row.Cells[1].Value; parm.Description = (string)row.Cells[2].Value; parm.Conditional = (string)row.Cells[3].Value; msc.Add(parm); } } } else if (dataGridView.Tag is List<BuildScript>) { List<BuildScript> al = dataGridView.Tag as List<BuildScript>; al.Clear(); foreach (DataGridViewRow row in dataGridView.Rows) { if (row.Cells[1].Value != null) { BuildScript bs = new BuildScript(); bs.Conditional = row.Cells[0].Value as string; bs.Script = row.Cells[1].Value as string; al.Add(bs); } } } else if (dataGridView.Tag is List<ApiTemplate>) { List<ApiTemplate> al = dataGridView.Tag as List<ApiTemplate>; al.Clear(); foreach (DataGridViewRow row in dataGridView.Rows) { if (!string.IsNullOrEmpty(row.Cells[0].Value as string)) { ApiTemplate at = new ApiTemplate(); at.FilePath = row.Cells[0].Value as string; at.Description = row.Cells[1].Value as string; al.Add(at); } } } else if (dataGridView.Tag is MFComponent) { foreach (DataGridViewRow row in dataGridView.Rows) { /* if ((bool)row.Cells[1].Value) { Library lib = row.Tag as Library; MFComponent comp = dataGridView.Tag as MFComponent; comp.Guid = lib.Guid; comp.Name = lib.Name; break; } */ } } }