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

            this.Location = location;
        }
Esempio 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()));
        }
Esempio 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) { }
        }
Esempio 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));
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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));
        }
Esempio 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);
        }
Esempio n. 10
0
        internal void CreateManifest(ItemLocation folder, SiteManifest manifest)
        {
            var file = new InMemoryFile(folder, new MemoryStream(manifest.ToByteArray()));

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