internal void ExportManifest(string fullpath, bool askForConfirmation = true, bool includeFilesSection = true) { if (File.Exists(fullpath) && askForConfirmation) { var confirmed = UIServices.Confirm( Resources.ConfirmToReplaceFile_Title, string.Format(CultureInfo.CurrentCulture, Resources.ConfirmToReplaceFile, fullpath)); if (!confirmed) { return; } } var rootPath = Path.GetDirectoryName(fullpath); using (Stream fileStream = File.Create(fullpath)) { var manifest = Manifest.Create(PackageMetadata); if (includeFilesSection) { var tempPath = Path.GetTempPath(); manifest.Files.AddRange(RootFolder.GetFiles().Select( f => new ManifestFile { Source = string.IsNullOrEmpty(f.OriginalPath()) || f?.OriginalPath()?.StartsWith(tempPath, StringComparison.OrdinalIgnoreCase) == true ? f.Path : PathUtility.RelativePathTo(rootPath, f.OriginalPath() !), Target = f.Path })
public virtual IEnumerable <T> Resolve() { var files = AllowedExtensions .SelectMany(x => RootFolder.GetFiles(x, SearchOption.AllDirectories)) .Select(GetItem) .WhereNotNull(); return(files); }
internal void ExportManifest(string fullpath, bool askForConfirmation = true, bool includeFilesSection = true) { if (File.Exists(fullpath) && askForConfirmation) { var confirmed = UIServices.Confirm( Resources.ConfirmToReplaceFile_Title, string.Format(CultureInfo.CurrentCulture, Resources.ConfirmToReplaceFile, fullpath)); if (!confirmed) { return; } } var rootPath = Path.GetDirectoryName(fullpath); using (Stream fileStream = File.Create(fullpath)) { var manifest = Manifest.Create(PackageMetadata); if (includeFilesSection) { var tempPath = Path.GetTempPath(); manifest.Files.AddRange(RootFolder.GetFiles().Select( f => new ManifestFile { Source = string.IsNullOrEmpty(f.OriginalPath()) || f.OriginalPath().StartsWith(tempPath, StringComparison.OrdinalIgnoreCase) ? f.Path : PathUtility.RelativePathTo(rootPath, f.OriginalPath()), Target = f.Path }) ); } using (var ms = new MemoryStream()) { try { manifest.Save(ms); ms.Position = 0; ManifestUtility.SaveToStream(ms, fileStream); } catch (Exception e) { UIServices.Show(e.Message, MessageLevel.Error); } } } }
public void AddSingleFile() { Files.Add("myfile.cs"); Create(); Is("myfile.cs", RootFolder.GetFiles().Single()); NewProjectState(); Files.Add("myfile.cs"); Files.Add("myfile2.cs"); Update(); Assert.AreEqual(2, RootFolder.Children.Count); Assert.IsTrue(Contains(RootFolder, "myfile.cs")); Assert.IsTrue(Contains(RootFolder, "myfile2.cs")); }
public void RemoveFolder() { Files.Add("myfile.cs"); Files.Add("sub1/myfile2.cs"); EmptyDirectories.Add("sub1/sub2"); Create(); Is("myfile.cs", RootFolder.GetFiles().Single()); Is("sub1", RootFolder.GetFolders().Single()); Assert.IsTrue(Contains(RootFolder.GetFolders().Single(), "sub1/myfile2.cs")); Assert.IsTrue(Contains(RootFolder.GetFolders().Single(), "sub1/sub2")); NewProjectState(); Files.Add("myfile.cs"); Update(); Assert.AreEqual(1, RootFolder.Children.Count); Assert.IsTrue(Contains(RootFolder, "myfile.cs")); }
protected override Icon GetItem(FileInfo file) { if (file.Extension.Equals(".css", StringComparison.InvariantCultureIgnoreCase)) { return(null); } //first, see if we've already got this sprite definition if (_sprites.Any(x => x.Key == file)) { return(null); } //see if there is an associated .CSS file for this current file //ensures we only resolve the files once if (_resolvedFiles == null) { _resolvedFiles = AllowedExtensions.SelectMany(x => RootFolder.GetFiles(x, SearchOption.AllDirectories)).ToArray(); } var spriteDefinition = _resolvedFiles .Where(x => x.Name.EndsWith(".css", StringComparison.InvariantCultureIgnoreCase)) .Where(x => Path.GetExtension(file.Name) != Path.GetExtension(x.Name)) .Where(x => Path.GetFileNameWithoutExtension(file.Name) == Path.GetFileNameWithoutExtension(x.Name)) .SingleOrDefault(); if (spriteDefinition != null) { _sprites.Add(new KeyValuePair <FileInfo, FileInfo>(file, spriteDefinition)); //since it's a Sprite, don't include it in the results return(null); } return(base.GetItem(file)); }
internal IEnumerable <IPackageFile> GetFiles() { return(RootFolder.GetFiles()); }
public void SingleFile() { Files.Add("myfile.cs"); Create(); Is("myfile.cs", RootFolder.GetFiles().Single()); }