private void DiscoverFiles(string rootPath, string searchText) { CurrentFiles.Clear(); CurrentFilesSelected.Clear(); if (rootPath != String.Empty) { DirectoryInfo di = new DirectoryInfo(rootPath); var files = di.EnumerateFiles("*", SearchOption.AllDirectories) .Where(f => ResourceExtensions.ValidExtensions.Contains(f.Extension)) .Where(f => f.Name != PACKAGES_FILENAME); if (!string.IsNullOrWhiteSpace(searchText)) { files = files.Where(f => f.FullName.Contains(searchText)); } foreach (FileInfo f in files) { CurrentFiles.Add(f); } OnPropertyChanged("CurrentFiles"); } }
private void DeleteSelectedPackage() { if (SelectedPackage != null) { var toBeDeleted = Packages.Where(x => x == SelectedPackage).FirstOrDefault(); if (toBeDeleted != null) { if (ActivePackage == SelectedPackage) { ActivePackage = null; //Also, clear out any dependencies CurrentFiles.Clear(); CurrentFilesSelected.Clear(); WebResourceInfos.Clear(); WebResourceInfosSelected.Clear(); } Packages.Remove(toBeDeleted); SelectedPackage = null; } SavePackages(); } }
private void AddFilesToWebResources(object parameter) { //Set the ActivePackage as Dirty. IsActivePackageDirty = true; //Clear the collection of selected files CurrentFilesSelected.Clear(); //List<FileInfo> selectedFiles = new List<FileInfo>(); if (parameter != null && parameter is IEnumerable) { foreach (var fileInfo in (IEnumerable)parameter) { CurrentFilesSelected.Add((FileInfo)fileInfo); } } if (CurrentFilesSelected.Count > 0) { foreach (FileInfo fi in CurrentFilesSelected) { //Add it to the list of web resource info, if not already there. //The matching criteria will be the ? XElement newInfo = ConvertFileInfoToWebResourceInfo(fi); if (WebResourceInfos.Where(w => w.Attribute("filePath").Value == newInfo.Attribute("filePath").Value).Count() == 0) { WebResourceInfos.Add(newInfo); } else { //it's already in the list! do nothing. } } } }