private static OptionClass GetOptionClass() { var optionClass = new OptionClass(); try { var xmlSerializer = new XmlSerializer(typeof(OptionClass)); using (var stream = File.Open(Path, FileMode.OpenOrCreate)){ using (var streamReader = new StreamReader(stream)){ var allText = streamReader.ReadToEnd(); if (!string.IsNullOrWhiteSpace(allText)) { var xmlReader = XmlReader.Create(new StringReader(allText)); if (xmlSerializer.CanDeserialize(xmlReader)) { optionClass = (OptionClass)xmlSerializer.Deserialize(xmlReader); } } } } } catch (Exception e) { DTE.LogError(e.ToString()); DTE.WriteToOutput(e.ToString()); } return(optionClass); }
static OptionClass() { try{ var directory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Xpand\VSIX\"; Path = System.IO.Path.Combine(directory, "Xpand.VSIX.Options.xml"); if (File.Exists(Path)) { Instance = GetOptionClass(); } else { if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } Instance = new OptionClass { KillModelEditor = true, SpecificVersion = true }; Instance.ConnectionStrings.Add(new ConnectionString() { Name = "ConnectionString" }); Instance.ConnectionStrings.Add(new ConnectionString() { Name = "WorldCreatorConnectionString" }); Instance.ConnectionStrings.Add(new ConnectionString() { Name = "EasyTestConnectionString" }); Instance.ConnectionStrings.Add(new ConnectionString() { Name = "NorthWind" }); var registryKey = Registry.LocalMachine.OpenSubKey(@"Software\WOW6432node\DevExpress\Components\"); if (registryKey != null) { foreach (var keyName in registryKey.GetSubKeyNames()) { directory = (string)registryKey.OpenSubKey(keyName)?.GetValue("RootDirectory"); Instance.ReferencedAssembliesFolders.Add(new ReferencedAssembliesFolder() { Folder = directory }); var sourceCodeInfo = new SourceCodeInfo { ProjectRegex = "DevExpress.*csproj", RootPath = directory }; sourceCodeInfo.AddProjectPaths(); Instance.SourceCodeInfos.Add(sourceCodeInfo); } } Instance.ReferencedAssembliesFolders.Add(new ReferencedAssembliesFolder() { Folder = ModuleManager.GetXpandDllPath() }); Instance.Exceptions.Add(new ExceptionsBreak() { Break = false, Exception = typeof(FileNotFoundException).FullName }); Instance.Exceptions.Add(new ExceptionsBreak() { Break = false, Exception = typeof(SqlException).FullName }); Instance.DisableExceptions = false; Instance.SourceCodeInfos.Add(new SourceCodeInfo { ProjectRegex = "Xpand.*csproj", RootPath = ModuleManager.GetXpandDllPath() + @"\..\" }); } if (!Instance.DteCommandsBindings) { Instance.DteCommandsBindings = true; Instance.DteCommands.Add(new DteCommand() { Command = nameof(BuildSelectionCommand), Shortcut = "Global::Ctrl+Alt+Enter" }); Instance.DteCommands.Add(new DteCommand() { Command = nameof(DuplicateLineCommand), Shortcut = "Text Editor::Ctrl+D" }); Instance.DteCommands.Add(new DteCommand() { Command = nameof(DropDataBaseCommand), Shortcut = "Global::Ctrl+Shift+Alt+D" }); Instance.DteCommands.Add(new DteCommand() { Command = $"Run{nameof(EasyTestCommand)}", Shortcut = "Text Editor::Alt+T" }); Instance.DteCommands.Add(new DteCommand() { Command = $"Debug{nameof(EasyTestCommand)}", Shortcut = "Text Editor::Alt+D" }); Instance.DteCommands.Add(new DteCommand() { Command = $"{nameof(FindInSolutionCommand)}", Shortcut = "Text Editor::Alt+Shift+L" }); Instance.DteCommands.Add(new DteCommand() { Command = $"{nameof(KillIISExpressCommand)}", Shortcut = "Global::Ctrl+Alt+Shift+I" }); Instance.DteCommands.Add(new DteCommand() { Command = $"{nameof(LoadProjectFromReferenceCommand)}", Shortcut = "Solution Explorer::Ctrl+Alt+Shift+L" }); Instance.DteCommands.Add(new DteCommand() { Command = $"{nameof(NavigateNextSubwordCommand)}", Shortcut = "Text Editor::ALT+Right Arrow" }); Instance.DteCommands.Add(new DteCommand() { Command = $"{nameof(NavigatePreviousSubwordCommand)}", Shortcut = "Text Editor::ALT+Left Arrow" }); Instance.DteCommands.Add(new DteCommand() { Command = $"{nameof(ShowModelsWindowCommand)}", Shortcut = "Global::Ctrl+Alt+Shift+M" }); Instance.DteCommands.Add(new DteCommand() { Command = $"{nameof(ShowOptionsCommand)}", Shortcut = "Global::Alt+Shift+0" }); } } catch (Exception e) { DTE.LogError(e.ToString()); throw; } }