asd
This commit is contained in:
20
Password Manager/Profiles/Profile.cs
Normal file
20
Password Manager/Profiles/Profile.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace Password_Manager
|
||||
{
|
||||
public delegate void PasswordStoreChange();
|
||||
|
||||
sealed class Profile
|
||||
{
|
||||
public string Name { get; } //the name of the password store profile ("personal", "work", or similar)
|
||||
public string Path { get; } //path of the folder containing the password store
|
||||
//public event PasswordStoreChange Change; //runs if a new password is added, or if one is removed
|
||||
|
||||
public Profile(string name, string path)
|
||||
{
|
||||
Name = name;
|
||||
Path = path;
|
||||
//Change = change;
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Password Manager/Profiles/ProfileHandler.cs
Normal file
17
Password Manager/Profiles/ProfileHandler.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace Password_Manager
|
||||
{
|
||||
static class ProfileHandler
|
||||
{
|
||||
public static Profile CurrentProfile;
|
||||
public static ProfileList ListOfProfiles;
|
||||
|
||||
public static void ProfileChange(object sender, EventArgs e)
|
||||
{
|
||||
Program.mainForm.searchBox.Clear();
|
||||
Program.mainForm.resultList.ReloadResults();
|
||||
Program.mainForm.profileSelection.DataSource = ListOfProfiles;
|
||||
}
|
||||
}
|
||||
}
|
||||
63
Password Manager/Profiles/ProfileList.cs
Normal file
63
Password Manager/Profiles/ProfileList.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
|
||||
namespace Password_Manager
|
||||
{
|
||||
sealed class ProfileList : IList<Profile>
|
||||
{
|
||||
public ProfileList() : base() { }
|
||||
|
||||
public override void Add(Profile p)
|
||||
{
|
||||
//grow the list by 1 and copy all existing items
|
||||
Profile[] tmp = new Profile[this.Length + 1];
|
||||
|
||||
for (int i = 0; i < this.Length; i++)
|
||||
{
|
||||
tmp[i] = this[i];
|
||||
}
|
||||
|
||||
this.list = tmp;
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
||||
list[this.Length - 1] = p;
|
||||
}
|
||||
|
||||
public override void Remove(Profile p)
|
||||
{
|
||||
Profile[] tmp = new Profile[this.Length - 1];
|
||||
|
||||
for (int i = 0; i < tmp.Length; i++)
|
||||
{
|
||||
if (this[i] != p)
|
||||
{
|
||||
tmp[i] = this[i];
|
||||
}
|
||||
}
|
||||
|
||||
this.list = tmp;
|
||||
}
|
||||
|
||||
public override Profile SearchByName(string name)
|
||||
{
|
||||
Profile result = null;
|
||||
|
||||
for (int i = 0; i < this.Length; i++)
|
||||
{
|
||||
if (this[i].Name == name)
|
||||
{
|
||||
result = this[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
throw new ProfileNotFoundException();
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Password Manager/Profiles/ProfileNotFoundException.cs
Normal file
13
Password Manager/Profiles/ProfileNotFoundException.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Password_Manager
|
||||
{
|
||||
sealed class ProfileNotFoundException : Exception
|
||||
{
|
||||
public ProfileNotFoundException() : base() { }
|
||||
public ProfileNotFoundException(string message) : base(message) { }
|
||||
public ProfileNotFoundException(string message, Exception inner) : base(message, inner) { }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user