Exemplo n.º 1
0
 protected void RemoveFile(ItemLocation fileLocation)
 {
     if (this._files == null)
     {
         Refresh();
     }
     _files.RemoveWhere(file => file.Location.Equals(fileLocation));
 }
Exemplo n.º 2
0
        public File(ItemLocation location)
        {
            if (location == null)
            {
                throw new ArgumentNullException("location");
            }

            this.Location = location;
        }
Exemplo n.º 3
0
        private SiteManifest LoadFile(ItemLocation potentialFile)
        {
            if (potentialFile == null)
            {
                throw new ArgumentNullException(nameof(potentialFile));
            }

            var manifest = fileSystemService.GetFile(potentialFile);

            return(SiteManifest.FromByteStream(manifest.GetContent()));
        }
Exemplo n.º 4
0
        /// <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) { }
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        internal void CreateManifest(ItemLocation folder, SiteManifest manifest)
        {
            var file = new InMemoryFile(folder, new MemoryStream(manifest.ToByteArray()));

            fileSystemService.SaveFile(file);
        }
Exemplo n.º 11
0
 public NamedMenuItem(ItemLocation location, Action action) : base(location, action)
 {
 }
Exemplo n.º 12
0
 public File GetFileAtLocation(ItemLocation location)
 {
     return(ContainedFiles.Where(f => f.Location.Equals(location)).FirstOrDefault());
 }
Exemplo n.º 13
0
 public abstract void Remove(ItemLocation fileLocation);
Exemplo n.º 14
0
 public MenuItem(ItemLocation location, Action action)
 {
     this.Location = location;
     this.Action   = action;
 }
Exemplo n.º 15
0
 internal ItemLocation Append(ItemLocation location)
 {
     throw new NotImplementedException();
 }