public static ExtensionSettings Load(string fileName)
    {
      ExtensionSettings settings;

      if (string.IsNullOrEmpty(fileName))
      {
        throw new ArgumentNullException("fileName");
      }

      settings = new ExtensionSettings();

      if (File.Exists(fileName))
      {
        try
        {
          using (FileStream stream = File.OpenRead(fileName))
          {
            settings = (ExtensionSettings)Serializer.Deserialize(stream);
          }
        }
          // ReSharper disable EmptyGeneralCatchClause
        catch
          // ReSharper restore EmptyGeneralCatchClause
        {
          // ignore exceptions
        }
      }

      return settings;
    }
示例#2
0
        public static bool ShowSettingsDialog(IWin32Window owner, ExtensionSettings settings)
        {
            bool result;

            using (FolderExclusionsDialog dialog = new FolderExclusionsDialog(settings.ExcludedFolders, settings.ProjectTypes))
            {
                result = dialog.ShowDialog(owner) == DialogResult.OK;

                if (result)
                {
                    // update the settings
                    // TODO: note they currently won't be saved as we don't have access to the filename right now
                    settings.ExcludedFolders.Clear();
                    settings.ExcludedFolders.AddRange(dialog.ExcludedFolders);

                    settings.ProjectTypes.Clear();
                    settings.ProjectTypes.AddRange(dialog.ProjectTypes);
                }
            }

            return(result);
        }
示例#3
0
 public FindProjectsDialog(ExtensionSettings settings)
     : this()
 {
     _settings = settings;
 }
 private void LoadSettings()
 {
   _settingsFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Cyotek\VisualStudioExtensions\AddProjects\config.xml");
   _settings = ExtensionSettings.Load(_settingsFileName);
 }
示例#5
0
 private void LoadSettings()
 {
     _settingsFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Cyotek\VisualStudioExtensions\AddProjects\config.xml");
     _settings         = ExtensionSettings.Load(_settingsFileName);
 }