Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Repository"/> class.
        /// </summary>
        /// <param name="localPath"></param>
        /// <param name="container"></param>
        public Repository(NPath localPath, ICacheContainer container)
        {
            Guard.ArgumentNotNull(localPath, nameof(localPath));

            LocalPath = localPath;

            cacheUpdateEvents = new Dictionary <CacheType, Action <CacheUpdateEvent> >
            {
                { CacheType.Branches, cacheUpdateEvent => {
                      LocalBranchListChanged?.Invoke(cacheUpdateEvent);
                      RemoteBranchListChanged?.Invoke(cacheUpdateEvent);
                      LocalAndRemoteBranchListChanged?.Invoke(cacheUpdateEvent);
                  } },
                { CacheType.GitAheadBehind, c => TrackingStatusChanged?.Invoke(c) },
                { CacheType.GitLocks, c => LocksChanged?.Invoke(c) },
                { CacheType.GitLog, c => LogChanged?.Invoke(c) },
                { CacheType.GitStatus, c => StatusEntriesChanged?.Invoke(c) },
                { CacheType.GitUser, cacheUpdateEvent => { } },
                { CacheType.RepositoryInfo, cacheUpdateEvent => {
                      CurrentBranchChanged?.Invoke(cacheUpdateEvent);
                      CurrentRemoteChanged?.Invoke(cacheUpdateEvent);
                      CurrentBranchAndRemoteChanged?.Invoke(cacheUpdateEvent);
                  } },
            };

            cacheContainer = container;
            cacheContainer.CacheInvalidated += CacheHasBeenInvalidated;
            cacheContainer.CacheUpdated     += (cacheType, offset) =>
            {
                cacheUpdateEvents[cacheType](new CacheUpdateEvent(cacheType, offset));
            };
        }
Esempio n. 2
0
 private void HandleBranchCacheUpdatedEvent(CacheUpdateEvent cacheUpdateEvent)
 {
     Logger.Trace("BranchCache Updated {0}", cacheUpdateEvent.UpdatedTimeString);
     LocalBranchListChanged?.Invoke(cacheUpdateEvent);
     RemoteBranchListChanged?.Invoke(cacheUpdateEvent);
     LocalAndRemoteBranchListChanged?.Invoke(cacheUpdateEvent);
 }