/// <summary> /// This function is the callback used to execute a command when the a menu item is clicked. /// See the Initialize method to see how the menu item is associated to this function using /// the OleMenuCommandService service and the MenuCommand class. /// </summary> private void MenuItemCallback(object sender, EventArgs e) { // Show a Message Box to prove we were here IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); Guid clsid = Guid.Empty; DeployConfiguration config = new DeployConfiguration(); SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider); WritableSettingsStore userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); if (!userSettingsStore.CollectionExists("SyncIIS")) { userSettingsStore.CreateCollection("SyncIIS"); } config.Domain = userSettingsStore.GetString("SyncIIS", "Domain", ""); config.SetSecurePassword(userSettingsStore.GetString("SyncIIS", "Password", "")); config.Site = userSettingsStore.GetString("SyncIIS", "Site", ""); config.Source = userSettingsStore.GetString("SyncIIS", "Source", ""); config.Target = userSettingsStore.GetString("SyncIIS", "Target", "").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()).ToList <string>(); config.Username = userSettingsStore.GetString("SyncIIS", "Username", ""); SyncWindow window = new SyncWindow(config); window.ShowDialog(); var settings = window.Configuration; userSettingsStore.SetString("SyncIIS", "Domain", settings.Domain); userSettingsStore.SetString("SyncIIS", "Password", settings.GetUnsecurePassword()); userSettingsStore.SetString("SyncIIS", "Site", settings.Site); userSettingsStore.SetString("SyncIIS", "Source", settings.Source); userSettingsStore.SetString("SyncIIS", "Target", string.Join(",", settings.Target.ToArray())); userSettingsStore.SetString("SyncIIS", "Username", settings.Username); }
/// <summary> /// This function is the callback used to execute a command when the a menu item is clicked. /// See the Initialize method to see how the menu item is associated to this function using /// the OleMenuCommandService service and the MenuCommand class. /// </summary> private void MenuItemCallback(object sender, EventArgs e) { // Show a Message Box to prove we were here IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); Guid clsid = Guid.Empty; DeployConfiguration config = new DeployConfiguration(); SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider); WritableSettingsStore userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); if (!userSettingsStore.CollectionExists("SyncIIS")) { userSettingsStore.CreateCollection("SyncIIS"); } config.Domain = userSettingsStore.GetString("SyncIIS", "Domain", ""); config.SetSecurePassword(userSettingsStore.GetString("SyncIIS", "Password", "")); config.Site = userSettingsStore.GetString("SyncIIS", "Site", ""); config.Source = userSettingsStore.GetString("SyncIIS", "Source", ""); config.Target = userSettingsStore.GetString("SyncIIS", "Target", "").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()).ToList<string>(); config.Username = userSettingsStore.GetString("SyncIIS", "Username", ""); SyncWindow window = new SyncWindow(config); window.ShowDialog(); var settings = window.Configuration; userSettingsStore.SetString("SyncIIS", "Domain", settings.Domain); userSettingsStore.SetString("SyncIIS", "Password", settings.GetUnsecurePassword()); userSettingsStore.SetString("SyncIIS", "Site", settings.Site); userSettingsStore.SetString("SyncIIS", "Source", settings.Source); userSettingsStore.SetString("SyncIIS", "Target", string.Join(",", settings.Target.ToArray())); userSettingsStore.SetString("SyncIIS", "Username", settings.Username); }