コード例 #1
0
 private string GetTargetFilterString(FilterPair filterPair)
 {
     if (Guid.Equals(new Guid(m_serverDiffEngine.Session.LeftMigrationSourceUniqueId), new Guid(filterPair.FilterItem[0].MigrationSourceUniqueId)))
     {
         return(VCTranslationService.TrimTrailingPathSeparator(filterPair.FilterItem[1].FilterString));
     }
     else
     {
         return(VCTranslationService.TrimTrailingPathSeparator(filterPair.FilterItem[0].FilterString));
     }
 }
コード例 #2
0
        public Endpoint(
            MonitorWatcher watcher,
            RuntimeEntityModel context,
            RTSession rtSession,
            RTMigrationSource rtMigrationSource,
            bool isRightMigrationSource,
            RTMigrationSource peerMigrationSource)
        {
            m_monitorWatcher = watcher;

            // TODO: Consider moving all of this initialization code to a new EndpointContext class that contains everything that the
            // Poll() method needs to do its job, and then have MonitorWatcher.GetEndpoints() pass the EndpointContext object as the single
            // arg to this constructor.

            this.Context                = context;
            this.RTMigrationSource      = rtMigrationSource;
            this.IsRightMigrationSource = isRightMigrationSource;
            this.PeerRTMigrationSource  = peerMigrationSource;

            BusinessModelManager businessModelManager = new BusinessModelManager();

            if (rtSession.SessionGroup == null)
            {
                rtSession.SessionGroupReference.Load();
            }

            Config = businessModelManager.LoadConfiguration(rtSession.SessionGroup.GroupUniqueId);
            if (Config == null)
            {
                throw new ApplicationException(
                          String.Format(CultureInfo.InvariantCulture, MigrationToolkitResources.SessionGroupNotFound,
                                        rtSession.SessionGroup.GroupUniqueId.ToString()));
            }

            // TODO: Modify ProdviderManager to take a constructor that does not require a Config and that just loads
            // all providers in the Plugins directory, then move this code up to the MonitorWatcher constructor and pass the
            // providerHandlers down as another argument to this constructor
            ProviderManager providerManager = new ProviderManager(Config);
            Dictionary <Guid, ProviderHandler> providerHandlers = providerManager.LoadProvider(new DirectoryInfo(Constants.PluginsFolderName));

            ProviderHandler providerHandler;

            if (!providerHandlers.TryGetValue(this.RTMigrationSource.UniqueId, out providerHandler))
            {
                throw new Exception(string.Format(CultureInfo.InvariantCulture,
                                                  MigrationToolkitResources.ProviderHandlerNotLoadedForMigrationSouce,
                                                  this.RTMigrationSource.FriendlyName));
            }

            Debug.Assert(providerHandler.Provider != null);
            SyncMonitorProvider = providerHandler.Provider.GetService(typeof(ISyncMonitorProvider)) as ISyncMonitorProvider;
            if (SyncMonitorProvider == null)
            {
                throw new NotImplementedException(string.Format(CultureInfo.InvariantCulture,
                                                                MigrationToolkitResources.ProviderDoesNotImplementISyncMonitor,
                                                                providerHandler.ProviderName));
            }

            // Find the Session object corresponding to the RTSession
            if (Config.SessionGroup != null && Config.SessionGroup.Sessions != null)
            {
                foreach (var aSession in Config.SessionGroup.Sessions.Session)
                {
                    if (string.Equals(aSession.SessionUniqueId, rtSession.SessionUniqueId.ToString(), StringComparison.Ordinal))
                    {
                        Session = aSession;
                        break;
                    }
                }
            }
            if (Session == null)
            {
                throw new Exception(string.Format(CultureInfo.InvariantCulture,
                                                  MigrationToolkitResources.SessionNotFoundForMigrationSource,
                                                  rtSession.SessionGroup.GroupUniqueId.ToString(), RTMigrationSource.FriendlyName));
            }

            Guid migrationSourceGuid = new Guid(isRightMigrationSource ? Session.RightMigrationSourceUniqueId : Session.LeftMigrationSourceUniqueId);

            Microsoft.TeamFoundation.Migration.BusinessModel.MigrationSource migrationSource = Config.GetMigrationSource(migrationSourceGuid);
            Session.MigrationSources.Add(migrationSourceGuid, migrationSource);

            var serviceContainer = new ServiceContainer();

            serviceContainer.AddService(typeof(ITranslationService), new SyncMonitorTranslationService(Session));
            // We pass null for the global Configuration to the ConfigurationService constructor because its not handy and not needed in this context
            serviceContainer.AddService(typeof(ConfigurationService), new ConfigurationService(null, Session, migrationSourceGuid));
            SyncMonitorProvider.InitializeServices(serviceContainer);
            SyncMonitorProvider.InitializeClient(migrationSource);

            int filterPairIndex = IsRightMigrationSource ? 1 : 0;

            foreach (var filterPair in Session.Filters.FilterPair)
            {
                if (!filterPair.Neglect)
                {
                    m_filterStrings.Add(VCTranslationService.TrimTrailingPathSeparator(filterPair.FilterItem[filterPairIndex].FilterString));
                }
            }
        }