예제 #1
0
        public static void AttachListener(this IRepositoryManagerListener listener, IRepositoryManager repositoryManager,
                                          RepositoryManagerAutoResetEvent managerAutoResetEvent = null, bool trace = false)
        {
            var logger = trace ? Logging.GetLogger <IRepositoryManagerListener>() : null;

            repositoryManager.OnIsBusyChanged += b => {
                logger?.Trace("OnIsBusyChanged: {0}", b);
                listener.OnIsBusyChanged(b);
                managerAutoResetEvent?.OnIsBusyChanged.Set();
            };

            repositoryManager.OnStatusUpdated += status => {
                logger?.Debug("OnStatusUpdated: {0}", status);
                listener.OnRepositoryChanged(status);
                managerAutoResetEvent?.OnRepositoryChanged.Set();
            };

            repositoryManager.OnActiveBranchChanged += () => {
                logger?.Trace("OnActiveBranchChanged");
                listener.OnActiveBranchChanged();
                managerAutoResetEvent?.OnActiveBranchChanged.Set();
            };

            repositoryManager.OnActiveRemoteChanged += () => {
                logger?.Trace("OnActiveRemoteChanged");
                listener.OnActiveRemoteChanged();
                managerAutoResetEvent?.OnActiveRemoteChanged.Set();
            };

            repositoryManager.OnHeadChanged += () => {
                logger?.Trace("OnHeadChanged");
                listener.OnHeadChanged();
                managerAutoResetEvent?.OnHeadChanged.Set();
            };

            repositoryManager.OnLocalBranchListChanged += () => {
                logger?.Trace("OnLocalBranchListChanged");
                listener.OnLocalBranchListChanged();
                managerAutoResetEvent?.OnLocalBranchListChanged.Set();
            };

            repositoryManager.OnRemoteBranchListChanged += () => {
                logger?.Trace("OnRemoteBranchListChanged");
                listener.OnRemoteBranchListChanged();
                managerAutoResetEvent?.OnRemoteBranchListChanged.Set();
            };

            repositoryManager.OnRemoteOrTrackingChanged += () => {
                logger?.Trace("OnRemoteOrTrackingChanged");
                listener.OnRemoteOrTrackingChanged();
                managerAutoResetEvent?.OnRemoteOrTrackingChanged.Set();
            };

            repositoryManager.OnLocksUpdated += locks => {
                var lockArray = locks.ToArray();
                logger?.Trace("OnLocksUpdated Count:{0}", lockArray.Length);
                listener.OnLocksUpdated(lockArray);
                managerAutoResetEvent?.OnLocksUpdated.Set();
            };
        }
예제 #2
0
        public static void AttachListener(this IRepositoryManagerListener listener, IRepositoryManager repositoryManager,
                                          RepositoryManagerEvents managerEvents = null, bool trace = true)
        {
            var logger = trace ? Logging.GetLogger <IRepositoryManagerListener>() : null;

            repositoryManager.OnIsBusyChanged += b => {
                logger?.Trace("OnIsBusyChanged: {0}", b);
                listener.OnIsBusyChanged(b);
                if (b)
                {
                    managerEvents?.OnIsBusy.Set();
                }
                else
                {
                    managerEvents?.OnIsNotBusy.Set();
                }
            };

            repositoryManager.OnStatusUpdated += status => {
                logger?.Debug("OnStatusUpdated: {0}", status);
                listener.OnStatusUpdate(status);
                managerEvents?.OnStatusUpdate.Set();
            };

            repositoryManager.OnActiveBranchChanged += (branch) => {
                logger?.Trace($"OnActiveBranchChanged {branch}");
                listener.OnActiveBranchChanged(branch);
                managerEvents?.OnActiveBranchChanged.Set();
            };

            repositoryManager.OnActiveRemoteChanged += (remote) => {
                logger?.Trace($"OnActiveRemoteChanged {(remote.HasValue ? remote.Value.Name : null)}");
                listener.OnActiveRemoteChanged(remote);
                managerEvents?.OnActiveRemoteChanged.Set();
            };

            repositoryManager.OnLocalBranchListChanged += () => {
                logger?.Trace("OnLocalBranchListChanged");
                listener.OnLocalBranchListChanged();
                managerEvents?.OnLocalBranchListChanged.Set();
            };

            repositoryManager.OnRemoteBranchListChanged += () => {
                logger?.Trace("OnRemoteBranchListChanged");
                listener.OnRemoteBranchListChanged();
                managerEvents?.OnRemoteBranchListChanged.Set();
            };

            repositoryManager.OnLocksUpdated += locks => {
                var lockArray = locks.ToArray();
                logger?.Trace("OnLocksUpdated Count:{0}", lockArray.Length);
                listener.OnLocksUpdated(lockArray);
                managerEvents?.OnLocksUpdated.Set();
            };
        }