I don't even know anymore
This commit is contained in:
@@ -2,32 +2,12 @@
|
||||
|
||||
namespace Password_Manager
|
||||
{
|
||||
sealed class ProfileList
|
||||
sealed class ProfileList : IList<Profile>
|
||||
{
|
||||
private Profile[] list;
|
||||
|
||||
public int Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.list.Length;
|
||||
}
|
||||
}
|
||||
public ProfileList() : base() { }
|
||||
|
||||
public Profile this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.list[index];
|
||||
}
|
||||
}
|
||||
|
||||
public ProfileList()
|
||||
{
|
||||
this.list = new Profile[0];
|
||||
}
|
||||
|
||||
public void Add(Profile p)
|
||||
public override void Add(Profile p)
|
||||
{
|
||||
//grow the list by 1 and copy all existing items
|
||||
Profile[] tmp = new Profile[this.Length + 1];
|
||||
@@ -44,7 +24,7 @@ namespace Password_Manager
|
||||
list[this.Length - 1] = p;
|
||||
}
|
||||
|
||||
public void Remove(Profile p)
|
||||
public override void Remove(Profile p)
|
||||
{
|
||||
Profile[] tmp = new Profile[this.Length - 1];
|
||||
|
||||
@@ -58,5 +38,27 @@ namespace Password_Manager
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user