63 lines
1.2 KiB
C#
63 lines
1.2 KiB
C#
|
|
using System;
|
|||
|
|
|
|||
|
|
namespace Password_Manager
|
|||
|
|
{
|
|||
|
|
sealed class ProfileList
|
|||
|
|
{
|
|||
|
|
private Profile[] list;
|
|||
|
|
|
|||
|
|
public int Length
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
return this.list.Length;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public Profile this[int index]
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
return this.list[index];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ProfileList()
|
|||
|
|
{
|
|||
|
|
this.list = new Profile[0];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public 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 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;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|