public bool initCreateStartEmptyProject(IDELauncherSetup projectSetup, out string errorMsg) { errorMsg = ""; this._setup = projectSetup; if (!Directory.Exists(this._setup.projectDirectoyPath)) { Directory.CreateDirectory(this._setup.projectDirectoyPath); } Assembly executingAssembly = Assembly.GetExecutingAssembly(); GlobalXMLManipulatorReader reader = new GlobalXMLManipulatorReader(executingAssembly.GetManifestResourceStream("NewWDS.Applications.IDE_Launcher.ProjectDescriptor.xml"), false); bool flag = false; bool flag2 = false; string replacement = ""; int num4 = reader.HowManyChildNode("RadioChip"); string path = ""; string str10 = ""; string str12 = ""; for (int i = 0; (i < num4) && !flag; i++) { reader.NavigateToChild("RadioChip", i); if (this._setup.radioChipType.Contains(reader.GetAttribute("name", false))) { int num3 = reader.HowManyChildNode("MCU"); for (int j = 0; (j < num3) && !flag; j++) { reader.NavigateToChild("MCU", j); reader.GetAttribute("name", false); if (reader.GetAttribute("name", false) == this._setup.mcu.ToString()) { int num2 = reader.HowManyChildNode("Vendor"); for (int k = 0; k < num2; k++) { reader.NavigateToChild("Vendor", k); if (reader.GetAttribute("name", false) == this._setup.toolVendor.ToString()) { reader.NavigateToChild("Project", 0); replacement = reader.GetAttribute("name", false); if (!Directory.Exists(this._setup.projectDirectoyPath + @"\" + replacement)) { Directory.CreateDirectory(this._setup.projectDirectoyPath + @"\" + replacement); } flag = true; break; } reader.NavigateUpOneLevel(); } } else { reader.NavigateUpOneLevel(); } } } else { reader.NavigateUpOneLevel(); } } if (flag) { StreamWriter writer; reader.NavigateToChild("WSP", 0); reader.NavigateToChild("FileName", 0); string str5 = reader.InnerText(); reader.NavigateUpOneLevel(); reader.NavigateToChild("FilePath", 0); reader.InnerText(); reader.NavigateUpOneLevel(); reader.NavigateToChild("ResourceName", 0); string str6 = reader.InnerText(); reader.NavigateUpOneLevel(); reader.NavigateUpOneLevel(); StreamReader reader2 = new StreamReader(executingAssembly.GetManifestResourceStream("NewWDS.Applications.IDE_Launcher.IDE_Project_Resources." + str6)); string input = reader2.ReadToEnd(); reader2.Close(); path = this._setup.projectDirectoyPath + @"\" + replacement + @"\" + str5; string pattern = "<WorkSpaceName>"; string str2 = path; input = Regex.Replace(input, pattern, str2); pattern = "<Vendor>"; switch (this._setup.toolVendor) { case IDELauncherSetup.ToolVendor.Keil: str2 = "0"; break; case IDELauncherSetup.ToolVendor.Raisonance: str2 = "1"; break; case IDELauncherSetup.ToolVendor.SDCC: str2 = "5"; break; } input = Regex.Replace(input, pattern, str2); pattern = "<Assembler>"; input = Regex.Replace(input, pattern, this._setup.assemblerExec); pattern = "<AssFlag>"; input = Regex.Replace(input, pattern, this._setup.assemblerFlags); pattern = "<AssFormat>"; input = Regex.Replace(input, pattern, this._setup.assemblerFormat); pattern = "<Compiler>"; input = Regex.Replace(input, pattern, this._setup.compilerExec); pattern = "<CompFlag>"; input = Regex.Replace(input, pattern, this._setup.compilerFlags); pattern = "<CompFormat>"; input = Regex.Replace(input, pattern, this._setup.compilerFormat); pattern = "<Linker>"; input = Regex.Replace(input, pattern, this._setup.linkerExec); pattern = "<LinkFlag>"; input = Regex.Replace(input, pattern, this._setup.linkerFlags); pattern = "<LinkFormat>"; input = Regex.Replace(input, pattern, this._setup.linkerFormat); pattern = "<OutputFile>"; input = Regex.Replace(input, pattern, replacement); int num = reader.HowManyChildNode("File"); int num9 = 0; int childNumber = 0; while (childNumber < num) { reader.NavigateToChild("File", childNumber); reader.NavigateToChild("FileName", 0); string str8 = reader.InnerText(); reader.NavigateUpOneLevel(); if (!this._setup.includeMCUHeaders && str8.Contains(this._setup.mcu.ToString())) { reader.NavigateUpOneLevel(); num9++; } else { string str11; reader.NavigateToChild("FilePath", 0); str10 = reader.InnerText(); reader.NavigateUpOneLevel(); reader.NavigateToChild("ResourceName", 0); string str9 = reader.InnerText(); reader.NavigateUpOneLevel(); if (this._setup.predefinedSourceFileStructure && (str10 != "")) { if (!Directory.Exists(this._setup.projectDirectoyPath + @"\" + replacement + @"\" + str10)) { Directory.CreateDirectory(this._setup.projectDirectoyPath + @"\" + replacement + @"\" + str10); } str11 = this._setup.projectDirectoyPath + @"\" + replacement + @"\" + str10 + @"\" + str8; } else { str11 = this._setup.projectDirectoyPath + @"\" + replacement + @"\" + str8; } Stream manifestResourceStream = executingAssembly.GetManifestResourceStream("NewWDS.Applications.IDE_Launcher.IDE_Project_Resources." + str9); FileStream stream2 = new FileStream(str11, FileMode.OpenOrCreate, FileAccess.Write); for (int m = 0; m < manifestResourceStream.Length; m++) { stream2.WriteByte((byte) manifestResourceStream.ReadByte()); } stream2.Close(); manifestResourceStream.Close(); pattern = "<HeaderFiles>"; str2 = "ptn_Child1=FileName\r\n[WorkState_v1_1.Header Files.FileName"; for (int n = 0; n < (childNumber - num9); n++) { str2 = str2 + ".FileName"; } if ((str10 == "") || !this._setup.predefinedSourceFileStructure) { string str13 = str2; str2 = str13 + "]\r\nFileName=" + str8 + "\r\n" + pattern + "\r\n"; str12 = this._setup.projectDirectoyPath + @"\" + replacement + @"\" + this._setup.radioChipType + "_" + this._setup.radioChipNickname + ".h"; } else { string str14 = str2; str2 = str14 + "]\r\nFileName=" + str10 + @"\" + str8 + "\r\n" + pattern + "\r\n"; str12 = this._setup.projectDirectoyPath + @"\" + replacement + @"\" + str10 + @"\" + this._setup.radioChipType + "_" + this._setup.radioChipNickname + ".h"; } input = Regex.Replace(input, pattern, str2); reader.NavigateUpOneLevel(); } childNumber++; } if (this._setup.includeRadioHeaders) { writer = new StreamWriter(str12); writer.Write(this._setup.radioChipHeader); writer.Close(); pattern = "<HeaderFiles>"; str2 = "ptn_Child1=FileName\r\n[WorkState_v1_1.Header Files.FileName"; for (int num12 = 0; num12 < (childNumber - num9); num12++) { str2 = str2 + ".FileName"; } if (!this._setup.predefinedSourceFileStructure) { string str15 = str2; str2 = str15 + "]\r\nFileName=" + this._setup.projectDirectoyPath + @"\" + replacement + @"\" + this._setup.radioChipType + "_" + this._setup.radioChipNickname + ".h\r\n" + pattern + "\r\n"; } else { string str16 = str2; str2 = str16 + "]\r\nFileName=" + str12 + "\r\n" + pattern + "\r\n"; } input = Regex.Replace(input, pattern, str2); } pattern = "<HeaderFiles>"; str2 = ""; input = Regex.Replace(input, pattern, str2); writer = new StreamWriter(path); writer.Write(input); writer.Close(); flag2 = true; } if (!flag || !flag2) { errorMsg = "The IDE Project was not created!\nCould not find proper project description for your setup!"; return false; } ProcessStartInfo startInfo = new ProcessStartInfo(this._setup.ideExecutable) { Arguments = path }; Process.Start(startInfo); return true; }
private int getAdtRecIDs(XmlNode appNode, List<int> adtRecIDList) { try { adtRecIDList.Clear(); GlobalXMLManipulatorReader reader = new GlobalXMLManipulatorReader(appNode); int num = reader.HowManyChildNode("ADT_Record_UniqId"); for (int i = 0; i < num; i++) { reader.NavigateToChild("ADT_Record_UniqId", i); adtRecIDList.Add(Convert.ToInt32(reader.InnerText())); reader.NavigateUpOneLevel(); } return 0; } catch { GlobalServices.ErrMsg("getAdtRecIDs()", "XML Format Error"); return -1; } }