Esempio n. 1
0
 private void RemoveFile(object file)
 {
     try
     {
         if (file != null)
         {
             var filePath     = (string)file;
             var fileName     = Path.GetFileNameWithoutExtension(filePath);
             var fileToRemove = FilesNameCollection.FirstOrDefault(f => f.FilePath.Equals(filePath));
             if (fileToRemove != null)
             {
                 FilesNameCollection.Remove(fileToRemove);
                 //remove the scripts which coresponds with the removed file from the grid
                 var scriptsToBeRemoved = ScriptsCollection.Where(s => s.Key.Equals(fileName)).ToList();
                 foreach (var script in scriptsToBeRemoved)
                 {
                     ScriptsCollection.Remove(script);
                 }
             }
             if (ScriptsCollection.Count.Equals(0))
             {
                 MessageVisibility = "Collapsed";
             }
         }
         SetGridVisibility();
     }
     catch (Exception ex)
     {
         Log.Logger.Error($"{Constants.RemoveFile}: {Constants.Message}: {ex.Message}\n " +
                          $"{Constants.StackTrace}: {ex.StackTrace}\n {Constants.InnerException}: {ex.InnerException}");
     }
 }
Esempio n. 2
0
 private void RemoveFile(object file)
 {
     if (file != null)
     {
         var filePath     = (string)file;
         var fileName     = Path.GetFileNameWithoutExtension(filePath);
         var fileToRemove = FilesNameCollection.FirstOrDefault(f => f.FilePath.Equals(filePath));
         if (fileToRemove != null)
         {
             FilesNameCollection.Remove(fileToRemove);
             //remove the scripts which coresponds with the removed file from the grid
             var scriptsToBeRemoved = ScriptsCollection.Where(s => s.Key.Equals(fileName)).ToList();
             foreach (var script in scriptsToBeRemoved)
             {
                 ScriptsCollection.Remove(script);
             }
         }
     }
     SetGridVisibility();
 }