public static void RemoveCodeAndDataDirs(bool confirmNeeded, string subject, string algorithm) { string subjectCodePath = ClassFactory.GenerateSubjectPath(subject); string subjectDataPath = Config.Instance.GenerateSubjectPath(subject); if (!(HasFiles(subjectCodePath) || HasFiles(subjectDataPath))) { if (CustomizedMessageBox.Show(new List <string> { "The subject CODE and DATA directories are empty. Do you want to delete them?" }, "FileUtils Message", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Directory.Delete(subjectCodePath, true); Directory.Delete(subjectDataPath, true); return; } } string algorithmCodePath = ClassFactory.GenerateAlgorithmPath(subject, algorithm); string algorithmDataPath = Config.Instance.GenerateAlgorithmPath(subject, algorithm); if (!(HasFiles(algorithmCodePath) || HasFiles(algorithmDataPath))) { if (CustomizedMessageBox.Show(new List <string> { "The algorithm CODE and DATA directories are empty. Do you want to delete them?" }, "FileUtils Message", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Directory.Delete(algorithmCodePath, true); Directory.Delete(algorithmDataPath, true); return; } } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public static void CreateCodeDir(string subject, string algorithm) /// /// \brief Creates code dir. /// /// \par Description. /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 13/12/2017 /// /// \param subject (string) - The subject. /// \param algorithm (string) - The algorithm. //////////////////////////////////////////////////////////////////////////////////////////////////// public static void CreateCodeDir(string subject, string algorithm) { string subjectPath = ClassFactory.GenerateSubjectPath(subject); if (!Directory.Exists(subjectPath)) { CreateDirectory(Path.GetFullPath(subjectPath)); } string algorithmPath = ClassFactory.GenerateAlgorithmPath(subject, algorithm); if (!Directory.Exists(algorithmPath)) { CreateDirectory(Path.GetFullPath(algorithmPath)); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public void CreateCodeFile() /// /// \brief Creates code file. /// /// \par Description. /// The main method for creating the code file /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 18/03/2018 //////////////////////////////////////////////////////////////////////////////////////////////////// public void CreateCodeFile() { InitSyntaxHighlight(); // The header of the file string fileText = eol + "using System.Collections.Generic;"; fileText += eol + "using DistributedAlgorithms;"; fileText += eol + "using DistributedAlgorithms.Algorithms.Base.Base;"; // The NetworkElement partial class if (!CreateNetworkElementText(ref fileText)) { CustomizedMessageBox.Show("Base algorithm code building cancelled by the user", "BaseAlgorithmAccess", null); return; } // The base algorithm partial class NetworkElement[] networkElements = { new BaseMessage(), new BaseNetwork(), new BaseProcess(), new BaseChannel() }; classNames[0] = "Message"; string[] enumClasses = { "bm", "bn", "bp", "bc" }; fileText += eol + @"namespace DistributedAlgorithms.Algorithms." + "Base" + "." + "Base" + eol + "{"; for (classIdx = 0; classIdx < classNames.Count; classIdx++) { networkElements[classIdx].Init(0); if (!CreateBaseClassText(ref fileText, networkElements[classIdx], enumClasses[classIdx])) { CustomizedMessageBox.Show("Base algorithm code building cancelled by the user", "BaseAlgorithmAccess", null); return; } } fileText += eol + "}"; classNames[0] = "Process"; File.WriteAllText(ClassFactory.GenerateAlgorithmPath("Base", "Base") + "\\" + "Base" + "DefsAndInits" + ".cs", fileText); CustomizedMessageBox.Show("Base algorithm code building finished", "BaseAlgorithmAccess", null, Icons.Success); }