protected void RemoveFile(ItemLocation fileLocation) { if (this._files == null) { Refresh(); } _files.RemoveWhere(file => file.Location.Equals(fileLocation)); }
public File(ItemLocation location) { if (location == null) { throw new ArgumentNullException("location"); } this.Location = location; }
private SiteManifest LoadFile(ItemLocation potentialFile) { if (potentialFile == null) { throw new ArgumentNullException(nameof(potentialFile)); } var manifest = fileSystemService.GetFile(potentialFile); return(SiteManifest.FromByteStream(manifest.GetContent())); }
/// <summary> /// Performs a compare operation using the specified FileComparer with the two files at the specified location. /// </summary> /// <param name="location"></param> public void Compare(ItemLocation location, IFileComparer fileComparer) { File left = Left.GetFileAtLocation(location); File right = Right.GetFileAtLocation(location); //TODO: Show a message saying that one of the files does not exist. if (left == null || right == null) { return; } try { fileComparer.Compare(left, right); } catch (Exception) { } }
public static ItemLocation FromRelativeFilePath(string file) { if (file == null) { throw new ArgumentNullException(nameof(file)); } if (!file.StartsWith(Path.DirectorySeparatorChar.ToString())) { throw new ArgumentException($"path: {file} does not start with {Path.DirectorySeparatorChar}"); } string fileName = Path.GetFileName(file); string folderPath = Path.GetDirectoryName(file); IEnumerable <string> paths = folderPath.Split(Path.DirectorySeparatorChar); return(ItemLocation.FromFolderTree(paths).SetName(fileName)); }
internal static ItemLocation FromFolderTree(IEnumerable <string> currentRelativePath) { if (currentRelativePath == null || !currentRelativePath.Any()) { return(new ItemLocation("", "")); } ItemLocation initial = new ItemLocation(currentRelativePath.First(), ""); while (currentRelativePath.Any()) { initial.AddFolder(currentRelativePath.First()); currentRelativePath = currentRelativePath.Skip(1); } return(initial); }
public IEnumerable <string> GetFolderSimilarities(ItemLocation two) { if (two == null) { throw new ArgumentNullException("two"); } List <string> ret = new List <string>(); foreach (var x in this.Folders.Zip(two.Folders, (a, b) => new Tuple <string, string>(a, b))) { if (!x.Item1.Equals(x.Item2)) { break; } ret.Add(x.Item1); } return(ret); }
public override bool Equals(object obj) { if (obj == null) { return(false); } ItemLocation test = obj as ItemLocation; if (test == null) { return(false); } if (this.ItemName != test.ItemName) { return(false); } return(this.folders.SequenceEqual(test.Folders)); }
public static IEnumerable <ItemLocation> GetDistinctFolders(IEnumerable <ItemLocation> locations) { //TODO: Tests List <ItemLocation> ret = new List <ItemLocation>(); foreach (var loc in locations) { List <string> folders = new List <string>(); foreach (string folder in loc.Folders) { folders.Add(folder); ItemLocation l = ItemLocation.FromFolderTree(folders); if (!ret.Contains(l)) { ret.Add(l); } } } return(ret); }
internal void CreateManifest(ItemLocation folder, SiteManifest manifest) { var file = new InMemoryFile(folder, new MemoryStream(manifest.ToByteArray())); fileSystemService.SaveFile(file); }
public NamedMenuItem(ItemLocation location, Action action) : base(location, action) { }
public File GetFileAtLocation(ItemLocation location) { return(ContainedFiles.Where(f => f.Location.Equals(location)).FirstOrDefault()); }
public abstract void Remove(ItemLocation fileLocation);
public MenuItem(ItemLocation location, Action action) { this.Location = location; this.Action = action; }
internal ItemLocation Append(ItemLocation location) { throw new NotImplementedException(); }