/// <summary> /// Creates the default configuration. /// </summary> public static SwitchConfiguration CreateDefaultConfiguration() { var configuration = new SwitchConfiguration { EnableSwitchBetweenDesignerAndCodeBehind = true, EnableSwitchBetweenInterfaceAndImplementation = true, ExtensionSwitches = new List <ExtensionSwitch>() }; // C/C++ extensions. configuration.ExtensionSwitches.Add(new ExtensionSwitch("c", "h")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("cpp", "h")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("cxx", "h")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("h", "c")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("h", "cpp")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("h", "cxx")); // Add the XAML extensions. configuration.ExtensionSwitches.Add(new ExtensionSwitch("xaml", "xaml.cs")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("xaml.cs", "xaml")); // Add the ASPX extensions. configuration.ExtensionSwitches.Add(new ExtensionSwitch("master", "master.cs")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("master.cs", "master.designer.cs")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("master.designer.cs", "master")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("asax", "asax.cs")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("asax.cs", "asax")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("aspx", "aspx.cs")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("aspx.cs", "aspx.designer.cs")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("aspx.designer.cs", "aspx")); // Return the configuration. return(configuration); }
/// <summary> /// Creates the default configuration. /// </summary> public static SwitchConfiguration CreateDefaultConfiguration() { var configuration = new SwitchConfiguration { EnableSwitchBetweenDesignerAndCodeBehind = true, EnableSwitchBetweenInterfaceAndImplementation = true, ExtensionSwitches = new List<ExtensionSwitch>() }; // C/C++ extensions. configuration.ExtensionSwitches.Add(new ExtensionSwitch("c", "h")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("cpp", "h")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("cxx", "h")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("h", "c")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("h", "cpp")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("h", "cxx")); // Add the XAML extensions. configuration.ExtensionSwitches.Add(new ExtensionSwitch("xaml", "xaml.cs")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("xaml.cs", "xaml")); // Add the ASPX extensions. configuration.ExtensionSwitches.Add(new ExtensionSwitch("master", "master.cs")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("master.cs", "master.designer.cs")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("master.designer.cs", "master")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("asax", "asax.cs")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("asax.cs", "asax")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("aspx", "aspx.cs")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("aspx.cs", "aspx.designer.cs")); configuration.ExtensionSwitches.Add(new ExtensionSwitch("aspx.designer.cs", "aspx")); // Return the configuration. return configuration; }
/// <summary> /// Saves the configuration. /// </summary> public static void SaveConfiguration(SwitchConfiguration switchConfiguration) { // Create the file. try { using (var stream = new FileStream(GetSwitchConfigurationPath(), FileMode.Create, FileAccess.Write)) { var serailzier = new XmlSerializer(typeof(SwitchConfiguration)); serailzier.Serialize(stream, switchConfiguration); } } catch (Exception exception) { throw new Exception(@"Failed to load the configuration for the Switch addin.", exception); } }
/// <summary> /// Resets the addin to the default configuration. /// </summary> public void LoadDefaultConfiguration() { Configuration = SwitchConfigurationManager.CreateDefaultConfiguration(); }
/// <summary> /// Loads the configuration. /// </summary> public void LoadConfiguration() { try { Configuration = SwitchConfigurationManager.LoadConfiguration(); } catch (Exception exception) { HandleException(@"Failed to load the configuration for the Switch addin.", exception); } }
/// <summary> /// Loads the configuration. /// </summary> public void LoadConfiguration() { if (!File.Exists(GetSwitchConfigurationPath())) { CreateDefaultConfiguration(); return; } // Open the file. try { using (var stream = new FileStream(GetSwitchConfigurationPath(), FileMode.Open, FileAccess.Read)) { var serailzier = new XmlSerializer(typeof (SwitchConfiguration)); Configuration = (SwitchConfiguration) serailzier.Deserialize(stream); } } catch (Exception exception) { HandleException(@"Failed to load the configuration for the Switch addin.", exception); } }