/// <summary>
        /// This method was copied (and slightly modified) from Microsoft.VisualStudio.ExtensionManager.ExtensionEngineImpl
        /// Internal method subject to change. Last pulled: 02-Jan-2018
        /// </summary>
        /// <returns></returns>
        internal static long GetLastExtensionChangedTimestampInternal()
        {
            ShellSettingsManager manager = new ShellSettingsManager(ServiceProvider.GlobalProvider);

            string perMachineExtensionInstallRoot = manager.GetApplicationDataFolder(ApplicationDataFolder.ApplicationExtensions);

            long          lastConfigChange     = 0;
            List <string> changeIndicatorFiles = new List <string>();

            SettingsStore configurationSettingsStore = manager.GetReadOnlySettingsStore(SettingsScope.Configuration);

            using (configurationSettingsStore as IDisposable)
            {
                // Check machine level user configuration timestamp
                changeIndicatorFiles.Add(Path.Combine(perMachineExtensionInstallRoot, ExtensionsConfigurationChanged));

                // Check product level timestamp (detect changes global to all SKUs).
                //changeIndicatorFiles.Add(Path.Combine(engineHost.ShellFolder, ExtensionsConfigurationChanged));

                foreach (var changeIndicatorFilePath in changeIndicatorFiles)
                {
                    FileInfo fi = new FileInfo(changeIndicatorFilePath);
                    if (fi.Exists)
                    {
                        long fileWriteTime = fi.LastWriteTimeUtc.ToFileTimeUtc();
                        if (fileWriteTime > lastConfigChange)
                        {
                            lastConfigChange = fileWriteTime;
                            //reason = EngineConstants.ReasonFileWriteTime;
                        }
                    }
                }

                // Check configuration settings timestamp
                long configSettingsTime = configurationSettingsStore.GetInt64(string.Empty, ConfigurationChangedKey, 0L);
                if (configSettingsTime > lastConfigChange)
                {
                    lastConfigChange = configSettingsTime;
                    //reason = EngineConstants.ReasonConfigSettingsTime;
                }
            }

            SettingsStore userSettings = manager.GetReadOnlySettingsStore(SettingsScope.UserSettings);

            using (userSettings as IDisposable)
            {
                // Check user settings timestamp
                long userSettingsTime = userSettings.GetInt64(string.Empty, ConfigurationChangedKey, 0L);
                if (userSettingsTime > lastConfigChange)
                {
                    lastConfigChange = userSettingsTime;
                    //reason = EngineConstants.ReasonUserSettingsTime;
                }

                // Check extensions changed timestamp (this will pick up all changes made through extension manager service)
                long extensionsChangedTime = userSettings.GetInt64(SettingsStoreRoot, ExtensionsChangedKey, 0L);
                if (extensionsChangedTime > lastConfigChange)
                {
                    lastConfigChange = extensionsChangedTime;
                    //reason = EngineConstants.ReasonExtensionsChangedTime;
                }
            }

            return(lastConfigChange);
        }
Exemplo n.º 2
0
 public int GetInt64([ComAliasName("OLE.LPCOLESTR")] string collectionPath, [ComAliasName("OLE.LPCOLESTR")] string propertyName, out long value)
 {
     value = inner.GetInt64(collectionPath, propertyName);
     return(0);
 }