예제 #1
0
        public IEnumerable <Change> GetChanges(IEnumerable <ISourceItem> remoteItems)
        {
            List <Change> changes = new List <Change>();

            foreach (var remoteItem in remoteItems)
            {
                LocalRepositoryFile localFile;
                if (Files.TryGetValue(remoteItem.Url, out localFile))
                {
                    if (localFile.Version != remoteItem.Version)
                    {
                        localFile.Version = remoteItem.Version;
                        localFile.Source  = remoteItem;
                        changes.Add(new Change {
                            Type = ChangeType.Modified, RepositoryFile = localFile
                        });
                    }
                }
                else
                {
                    localFile = new LocalRepositoryFile
                    {
                        Name        = remoteItem.Name,
                        Folder      = remoteItem.Folder,
                        Version     = remoteItem.Version,
                        Url         = remoteItem.Url,
                        IsDirectory = remoteItem.IsDirectory,
                        Source      = remoteItem
                    };
                    changes.Add(new Change {
                        Type = ChangeType.Added, RepositoryFile = localFile
                    });
                }
            }

            foreach (var item in Files.Values.ToList())
            {
                if (!remoteItems.Any(x => x.Url == item.Url))
                {
                    changes.Add(new Change {
                        Type = ChangeType.Removed, RepositoryFile = item
                    });
                    Files.Remove(item.Url);
                }
            }

            // clear local cache..
            //Files.Clear();

            return(changes);
        }
예제 #2
0
        public IEnumerable<Change> GetChanges(IEnumerable<ISourceItem> remoteItems)
        {
            List<Change> changes = new List<Change>();

            foreach (var remoteItem in remoteItems)
            {
                LocalRepositoryFile localFile;
                if (Files.TryGetValue(remoteItem.Url, out localFile))
                {
                    if (localFile.Version != remoteItem.Version)
                    {
                        localFile.Version = remoteItem.Version;
                        localFile.Source = remoteItem;
                        changes.Add(new Change { Type = ChangeType.Modified, RepositoryFile = localFile });
                    }
                }
                else
                {
                    localFile = new LocalRepositoryFile
                    {
                        Name = remoteItem.Name,
                        Folder = remoteItem.Folder,
                        Version = remoteItem.Version,
                        Url = remoteItem.Url,
                        IsDirectory = remoteItem.IsDirectory,
                        Source = remoteItem
                    };
                    changes.Add(new Change { Type = ChangeType.Added, RepositoryFile = localFile });
                }
            }

            foreach (var item in Files.Values.ToList())
            {
                if (!remoteItems.Any(x => x.Url == item.Url))
                {
                    changes.Add(new Change { Type = ChangeType.Removed, RepositoryFile = item });
                    Files.Remove(item.Url);
                }
            }

            // clear local cache..
            //Files.Clear();

            return changes;
        }