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

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

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