/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { base.Initialize(); Logger.WriteInformation("Initializing"); try { HttpClient = new HttpClient(); HttpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0) (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"); var pSolution = (IVsSolution)GetService(typeof(SVsSolution)); var result = pSolution.AdviseSolutionEvents(new SolutionEventsHandler(), out SolutionEventsHandlerId); Settings = new Settings(); UserImages = new UserImageCache(); Redis = new RedisWrapper(); Slack = new SlackWrapper(); LocalIdeModel = new LocalIDEModel(); IDEWrapper = new IDEWrapper((EnvDTE.DTE)GetService(typeof(EnvDTE.DTE))); var versionedAssembly = GetVersionedAssembly(); SourceControlRepo = new CachedSourceControlRepository( new GitRepository(), GetVersionedType <ISourceControlRepository>(versionedAssembly, "TeamCoding.Documents.SourceControlRepositories.TeamFoundationServiceRepository"), new SolutionNameBasedRepository()); CaretInfoProvider = GetVersionedType <ICaretInfoProvider>(versionedAssembly, "TeamCoding.Documents.CaretInfoProvider"); CaretAdornmentDataProvider = GetVersionedType <ICaretAdornmentDataProvider>(versionedAssembly, "TeamCoding.Documents.CaretAdornmentDataProvider"); IdentityProvider = new CachedFailoverIdentityProvider(new VSOptionsIdentityProvider(), new CredentialManagerIdentityProvider(new[] { "git:https://github.com", "https://github.com/" }), new VSIdentityProvider(), new MachineIdentityProvider()); ConnectionWrapper = new SqlConnectionWrapper(); WindowsServiceClient = new WinServiceClient(Settings.SharedSettings.WinServiceIPAddressProperty); RemoteModelChangeManager = new CombinedRemoteModelPersister(new RedisRemoteModelPersister(), new SharedFolderRemoteModelPersister(), new SlackRemoteModelPersister(), new SqlServerRemoteModelPersister(ConnectionWrapper), new WinServiceRemoteModelPersister(WindowsServiceClient)); LocalModelChangeManager = new CombinedLocalModelPersister(new RedisLocalModelPersister(LocalIdeModel), new SharedFolderLocalModelPersister(LocalIdeModel), new SlackLocalModelPersister(LocalIdeModel), new SqlServerLocalModelPersister(ConnectionWrapper, LocalIdeModel), new WinServiceLocalModelPersister(WindowsServiceClient, LocalIdeModel)); RemoteModelChangeManager.RemoteModelReceived += RemoteModelChangeManager_RemoteModelReceived; TeamCoding.VisualStudio.ToolWindows.OverviewWindow.OverviewCommand.Initialize(this); } catch (Exception ex) when(!System.Diagnostics.Debugger.IsAttached) { Logger.WriteError(ex); } }
public LocalModelPersisterBase(LocalIDEModel model, params SettingProperty <string>[] settingProperties) { SettingProperties = settingProperties; IdeModel = model; IdeModel.ModelChanged += IdeModel_ModelChangedAsync; foreach (var property in SettingProperties) { property.Changing += SettingProperty_ChangingAsync; property.Changed += SettingProperty_ChangedAsync; } UserSettings = TeamCodingPackage.Current.Settings.UserSettings; UserSettings.ShowSelfChanged += UserSettings_ShowSelfChangedAsync; }
public FileBasedLocalModelPersisterBase(LocalIDEModel model) : base(model, TeamCodingPackage.Current.Settings.SharedSettings.FileBasedPersisterPathProperty) { FileHeartBeatCancelSource = new CancellationTokenSource(); FileHeartBeatCancelToken = FileHeartBeatCancelSource.Token; FileHeartBeatThread = new Thread(() => { while (!FileHeartBeatCancelToken.IsCancellationRequested) { if (PersistenceFolderPath == null || !Directory.Exists(PersistenceFolderPath)) { FileHeartBeatCancelToken.WaitHandle.WaitOne(5000); } else { try { var UTCNow = DateTime.UtcNow; var Difference = (UTCNow - LastFileWriteTime).TotalSeconds; if (Difference > 60) { // If there have been no changes in the last minute, write the file again (prevent it being tidied up by others) File.SetLastWriteTimeUtc(PersistenceFilePath, UTCNow); LastFileWriteTime = UTCNow; FileHeartBeatCancelToken.WaitHandle.WaitOne(1000 * 60); } else { FileHeartBeatCancelToken.WaitHandle.WaitOne(1000 * (60 - (int)Difference + 1)); } } catch (IOException) { FileHeartBeatCancelToken.WaitHandle.WaitOne(10000); } } } }); FileHeartBeatThread.Start(); }
public DebugLocalModelPersister(LocalIDEModel model) : base(model) { }
public SlackLocalModelPersister(LocalIDEModel model) : base(model, TeamCodingPackage.Current.Settings.SharedSettings.SlackTokenProperty, TeamCodingPackage.Current.Settings.SharedSettings.SlackChannelProperty) { }
public RedisLocalModelPersister(LocalIDEModel model) : base(model, TeamCodingPackage.Current.Settings.SharedSettings.RedisServerProperty) { }
public SharedFolderLocalModelPersister(LocalIDEModel model) : base(model) { }
public SqlServerLocalModelPersister(SqlConnectionWrapper connectionWrapper, LocalIDEModel model) : base(model, TeamCodingPackage.Current.Settings.SharedSettings.SqlServerConnectionStringProperty) { ConnectionWrapper = connectionWrapper; }
public WinServiceLocalModelPersister(WinServiceClient client, LocalIDEModel model) : base(model, TeamCodingPackage.Current.Settings.SharedSettings.WinServiceIPAddressProperty) { Client = client; }