Exemple #1
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.OnCurrentBranchAndRemoteUpdated += (configBranch, configRemote) => {
                logger?.Trace("OnCurrentBranchAndRemoteUpdated");
                listener.OnCurrentBranchAndRemoteUpdated(configBranch, configRemote);
                managerEvents?.OnCurrentBranchAndRemoteUpdated.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();
            };
        }
Exemple #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 += 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();
            };
        }