Esempio n. 1
0
        private static void CreateCSharpFiles(DartModel model, string destination)
        {
            foreach (var folder in model)
            {
                var destinationFolder = Path.Combine(destination, folder.Key);

                // Check Folder
                if (!Directory.Exists(destinationFolder))
                {
                    Directory.CreateDirectory(destinationFolder);
                }

                foreach (var file in folder.Value)
                {
                    // Create CSharp File
                    var csharpFile          = CSharpWriter.CreateFile(file, model);
                    var destinationFileName = $"{file.Name.Substring(0, file.Name.IndexOf("."))}.cs";

                    var destinationPath = Path.Combine(destinationFolder, destinationFileName);


                    if (!File.Exists(destinationFileName))
                    {
                        File.Create(destinationPath).Close();
                    }

                    File.WriteAllText(destinationPath, csharpFile);
                }
            }
        }