public static void Initialize() { if (ServiceProviderRegistration.GlobalProvider.GetService(typeof(SVsSettingsManager)) != null) return; var esm = ExternalSettingsManager.CreateForApplication(GetVersionExe(FindVsVersions().LastOrDefault().ToString())); var sp = new ServiceProviderMock { serviceInstances = { // Used by ServiceProvider { typeof(SVsActivityLog).GUID, new DummyLog() }, { typeof(SVsSettingsManager).GUID, new SettingsWrapper(esm) } } }; ServiceProviderRegistration.CreateFromSetSite(sp); // The designer loads Microsoft.VisualStudio.Shell.XX.0, // which we cannot reference directly (to avoid breaking // older versions). Therefore, I set the global property // for every available version using Reflection instead. foreach (var vsVersion in FindVsVersions().Where(v => v.Major >= 10)) { var type = Type.GetType("Microsoft.VisualStudio.Shell.ServiceProvider, Microsoft.VisualStudio.Shell." + vsVersion.ToString(2)); if (type == null) continue; type.GetMethod("CreateFromSetSite", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static) .Invoke(null, new[] { sp }); } }
public static void Initialize() { if (ServiceProviderRegistration.GlobalProvider.GetService(typeof(SVsSettingsManager)) != null) { return; } var esm = ExternalSettingsManager.CreateForApplication(GetVersionExe(FindVsVersions().LastOrDefault().ToString())); var sp = new ServiceProviderMock { serviceInstances = { // Used by ServiceProvider { typeof(SVsActivityLog).GUID, new DummyLog() }, { typeof(SVsSettingsManager).GUID, new SettingsWrapper(esm) } } }; ServiceProviderRegistration.CreateFromSetSite(sp); // The designer loads Microsoft.VisualStudio.Shell.XX.0, // which we cannot reference directly (to avoid breaking // older versions). Therefore, I set the global property // for every available version using Reflection instead. foreach (var vsVersion in FindVsVersions().Where(v => v.Major >= 10)) { var type = Type.GetType("Microsoft.VisualStudio.Shell.ServiceProvider, Microsoft.VisualStudio.Shell." + vsVersion.ToString(2)); if (type == null) { continue; } type.GetMethod("CreateFromSetSite", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static) .Invoke(null, new[] { sp }); } }
public DesignerThemeDictionary() { if (ServiceProvider.GlobalProvider.GetService(new Guid("FD57C398-FDE3-42c2-A358-660F269CBE43")) != null) { return; // Do nothing when hosted in VS } //AssemblyResolverHack.AddHandler(); ServiceProviderMock.Initialize(); service = Activator.CreateInstance(Type.GetType("Microsoft.VisualStudio.Platform.WindowManagement.ColorThemeService, Microsoft.VisualStudio.Platform.WindowManagement")); ThemeIndex = 0; }