|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- using SIE.IVSDK.Services;
- using SIE.VSDK.Exceptions.DirectoryDestination;
- using SIE.VSDK.Exceptions.Solution;
- using SIE.VSDK.Extensions;
- using System.Collections.Generic;
- using System.IO;
-
-
- namespace SIE.VSDK.Services
- {
- public class SolutionService : ISolutionService
- {
- private readonly IPathService _pathService;
- public SolutionService(IPathService pathService)
- {
- _pathService = pathService;
- }
- public void CreateProjectTemplatesFromSolution(string solutionPath, string directoryDestinationPath, string newSolutionName)
- {
-
- if(solutionPath==null)
- {
- throw new SolutionPathIsNullException($"Le chemin de la solution {Path.GetFileName(solutionPath)} ne doit pas être null !");
- }
- if(solutionPath.Trim() == string.Empty)
- {
- throw new SolutionPathIsEmptyException($"Le chemin de la solution {Path.GetFileName(solutionPath)} ne doit pas être vide !");
- }
- if (!_pathService.IsValidPath(solutionPath))
- {
- throw new InvalidSolutionPathException($"Le chemin de la solution {Path.GetFileName(solutionPath)} n'est pas valide !");
- }
- if (Path.GetExtension(solutionPath) != ".sln")
- {
- throw new ExtensionSolutionPathException($"Le chemin de la solution {Path.GetFileName(solutionPath)} doit être d'extension .sln !");
- }
-
- if (!File.Exists(solutionPath))
- {
- throw new SolutionPathIsNotAFileException($"Le chemin de la solution {Path.GetFileName(solutionPath)} doit être un fichier existant!");
-
- }
- if(directoryDestinationPath ==null)
- {
- throw new DirectoryDestinationIsNullException($"Le chemin de destination {directoryDestinationPath} ne doit pas être null !");
- }
- if(directoryDestinationPath.Trim()==string.Empty)
- {
- throw new DirectoryDestinationIsEmptyException($"Le chemin de destination {directoryDestinationPath} ne doit pas être vide !");
- }
-
-
- if(!_pathService.IsValidPath(directoryDestinationPath))
- {
- throw new InvalideDirectoryDestinationException($"Le chemin de destination {directoryDestinationPath} n'est pas valide !");
-
- }
- if(!Directory.Exists(directoryDestinationPath))
- {
- throw new DirectoryDestinationNotFoundException($"Le dossier de destination {directoryDestinationPath} n'existe pas!");
- }
- if (newSolutionName == null)
- {
- throw new NewSolutionIsNullException("Le nom de la nouvelle solution est null");
- }
- if (newSolutionName.Trim() == string.Empty)
- {
- throw new NewSolutionIsEmptyException("Le nom de la nouvelle solution est vide");
- }
- if (Path.GetExtension(newSolutionName) != ".sln")
-
- {
- throw new ExtensionNewSolutionException($"Le nom de la nouvelle solution {newSolutionName} doit être de type .sln !");
- }
- string VSDK_ECOLOCALE_directory = Path.Combine(directoryDestinationPath, "VSDK_ECOLOCALE");
- if (!Directory.Exists(VSDK_ECOLOCALE_directory))
- {
- Directory.CreateDirectory(VSDK_ECOLOCALE_directory);
- }
- string TMP_TEMPLATE_directory = Path.Combine(VSDK_ECOLOCALE_directory, "TMP_TEMPLATE");
- if (!Directory.Exists(TMP_TEMPLATE_directory))
- {
- Directory.CreateDirectory(TMP_TEMPLATE_directory);
- }
- string TMP_SLN_directory = Path.Combine(TMP_TEMPLATE_directory, Path.GetFileNameWithoutExtension(newSolutionName));
- if (!Directory.Exists(TMP_SLN_directory))
- {
- Directory.CreateDirectory(TMP_SLN_directory);
- }
- DirectoryInfo sourceDir = new DirectoryInfo(Path.GetDirectoryName(solutionPath));
- sourceDir.DeepCopy(TMP_SLN_directory);
- string oldName = Path.Combine(TMP_SLN_directory, Path.GetFileName(solutionPath));
- File.Delete(oldName);
- sourceDir = new DirectoryInfo(Path.GetDirectoryName(TMP_SLN_directory));
- List<string> csProjFiles = sourceDir.GetCsProjFiles();
-
-
-
-
-
-
- }
- }
- }
|