Esempio n. 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();
            };
        }
Esempio n. 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();
            };
        }
Esempio n. 3
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 += isBusy => {
                logger?.Trace("OnIsBusyChanged: {0}", isBusy);
                listener.OnIsBusyChanged(isBusy);
                if (isBusy)
                {
                    managerEvents?.OnIsBusy.Set();
                }
                else
                {
                    managerEvents?.OnIsNotBusy.Set();
                }
            };

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

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

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

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

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

            repositoryManager.OnRemoteBranchListUpdated += (remotesList, branchList) => {
                logger?.Trace("OnRemoteBranchListUpdated");
                listener.OnRemoteBranchListUpdated(remotesList, branchList);
                managerEvents?.OnRemoteBranchListUpdated.Set();
            };

            repositoryManager.OnLocalBranchUpdated += name => {
                logger?.Trace("OnLocalBranchUpdated Name:{0}", name);
                listener.OnLocalBranchUpdated(name);
                managerEvents?.OnLocalBranchUpdated.Set();
            };

            repositoryManager.OnLocalBranchAdded += name => {
                logger?.Trace("OnLocalBranchAdded Name:{0}", name);
                listener.OnLocalBranchAdded(name);
                managerEvents?.OnLocalBranchAdded.Set();
            };

            repositoryManager.OnLocalBranchRemoved += name => {
                logger?.Trace("OnLocalBranchRemoved Name:{0}", name);
                listener.OnLocalBranchRemoved(name);
                managerEvents?.OnLocalBranchRemoved.Set();
            };

            repositoryManager.OnRemoteBranchAdded += (origin, name) => {
                logger?.Trace("OnRemoteBranchAdded Origin:{0} Name:{1}", origin, name);
                listener.OnRemoteBranchAdded(origin, name);
                managerEvents?.OnRemoteBranchAdded.Set();
            };

            repositoryManager.OnRemoteBranchRemoved += (origin, name) => {
                logger?.Trace("OnRemoteBranchRemoved Origin:{0} Name:{1}", origin, name);
                listener.OnRemoteBranchRemoved(origin, name);
                managerEvents?.OnRemoteBranchRemoved.Set();
            };

            repositoryManager.OnGitUserLoaded += user => {
                logger?.Trace("OnGitUserLoaded Name:{0}", user);
                listener.OnGitUserLoaded(user);
                managerEvents?.OnGitUserLoaded.Set();
            };
        }