Converting to file-scoped namespaces

This commit is contained in:
2023-04-02 22:10:42 +02:00
parent 2637741703
commit 4f3a768432
11 changed files with 525 additions and 536 deletions

View File

@@ -1,7 +1,7 @@
namespace Common
namespace Common;
class Config
{
class Config
{
public string PasswordStorePath { get; set; }
public string Recipient { get; set; }
@@ -10,5 +10,4 @@ namespace Common
this.PasswordStorePath = PasswordStorePath;
this.Recipient = Recipient;
}
}
}

View File

@@ -1,9 +1,9 @@
using Microsoft.VisualBasic.FileIO;
namespace Common
namespace Common;
static class ConfigFileManager
{
static class ConfigFileManager
{
#region Config flags
/*Configuration: (format: fieldname=value)
@@ -90,5 +90,4 @@ namespace Common
MessageBox.Show(e.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@@ -1,9 +1,8 @@
namespace Common
namespace Common;
class InvalidConfigurationException : Exception
{
class InvalidConfigurationException : Exception
{
public InvalidConfigurationException() : base() { }
public InvalidConfigurationException(string message) : base(message) { }
public InvalidConfigurationException(string message, Exception inner) : base(message, inner) { }
}
}

View File

@@ -1,9 +1,9 @@
using System.Text;
namespace Common
namespace Common;
static class PasswordGenerator
{
static class PasswordGenerator
{
private static string RandomStr(int length, bool no_symbols = false)
{
StringBuilder builder = new StringBuilder();
@@ -35,5 +35,4 @@ namespace Common
{
return new ProcessBuilder().GetOutput("cmd.exe", $"echo {RandomStr(length, no_symbols)} | gpg --quiet --encrypt --recipient {recipient}");
}
}
}

View File

@@ -1,12 +1,12 @@
using System.Diagnostics;
using System.Text;
namespace Common
namespace Common;
public delegate void ProcessSuccess();
public delegate void ProcessFailure(Exception e);
sealed class ProcessBuilder
{
public delegate void ProcessSuccess();
public delegate void ProcessFailure(Exception e);
sealed class ProcessBuilder
{
public event ProcessSuccess? ProcessFinished;
public event ProcessFailure? ProcessFailed;
@@ -57,5 +57,4 @@ namespace Common
return null;
}
}
}

View File

@@ -1,7 +1,7 @@
namespace GUI
namespace GUI;
partial class GeneratePassword
{
partial class GeneratePassword
{
/// <summary>
/// Required designer variable.
/// </summary>
@@ -132,5 +132,4 @@
private CheckBox noSymbols;
private Button generate;
private Button cancel;
}
}

View File

@@ -1,8 +1,8 @@
namespace GUI
namespace GUI;
public delegate void MethodRequest();
public partial class GeneratePassword : Form
{
public delegate void MethodRequest();
public partial class GeneratePassword : Form
{
private string currentPath;
private string recipient;
public event MethodRequest ReloadRequest;
@@ -52,5 +52,4 @@
{
Close();
}
}
}

View File

@@ -1,7 +1,7 @@
namespace GUI
namespace GUI;
sealed partial class MainForm : Form
{
sealed partial class MainForm : Form
{
/// <summary>
/// Required designer variable.
/// </summary>
@@ -111,5 +111,4 @@
private PasswordListBox ResultList;
private Button DecryptBtn;
private Button Cancel;
}
}

View File

@@ -1,7 +1,7 @@
namespace GUI
namespace GUI;
sealed public partial class MainForm : Form
{
sealed public partial class MainForm : Form
{
public event DataRequest PathRequest;
public event DataRequest? RecipientRequest;
@@ -65,5 +65,4 @@ namespace GUI
CopyAndNotify(pb.GetOutput("gpg.exe", $"--quiet --decrypt {PathRequest()}\\{ResultList.Text}"), ResultList.Text);
Close();
}
}
}

View File

@@ -1,10 +1,10 @@
using System.Collections;
namespace GUI
namespace GUI;
public delegate string SearchQuery();
public class PasswordListBox : ListBox
{
public delegate string SearchQuery();
public class PasswordListBox : ListBox
{
public event DataRequest? PathRequest;
public event SearchQuery? SearchQueryRequest;
@@ -69,5 +69,4 @@ namespace GUI
SelectedIndex = -1;
}
}
}
}

View File

@@ -1,8 +1,8 @@
namespace GUI
namespace GUI;
public delegate string DataRequest(); //Fire whenever a specific field of ProfileHandler.CurrentProfile is needed
internal static class Program
{
public delegate string DataRequest(); //Fire whenever a specific field of ProfileHandler.CurrentProfile is needed
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
@@ -18,5 +18,4 @@ namespace GUI
() => ConfigFileManager.GetPath(),
() => ConfigFileManager.GetRecipient()
); //needed at creation so that MainForm may pass this method down to other classes in its constructor
}
}