PageRenderTime 15ms CodeModel.GetById 12ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/src/NUnit/util/RecentFilesCollection.cs

#
C# | 57 lines | 41 code | 8 blank | 8 comment | 5 complexity | 9f205549c3cf26b22174c25a8a0ba3be MD5 | raw file
 1// ****************************************************************
 2// Copyright 2007, Charlie Poole
 3// This is free software licensed under the NUnit license. You may
 4// obtain a copy of the license at http://nunit.org
 5// ****************************************************************
 6
 7using System;
 8using System.Collections;
 9
10namespace NUnit.Util
11{
12	/// <summary>
13	/// Summary description for RecentFilesCollection.
14	/// </summary>
15	public class RecentFilesCollection : ReadOnlyCollectionBase
16	{
17		public void Add( RecentFileEntry entry )
18		{
19			InnerList.Add( entry );
20		}
21
22		public void Insert( int index, RecentFileEntry entry )
23		{
24			InnerList.Insert( index, entry );
25		}
26
27		public void Remove( string fileName )
28		{
29			int index = IndexOf( fileName );
30			if ( index != -1 )
31				RemoveAt( index );
32		}
33
34		public void RemoveAt( int index )
35		{
36			InnerList.RemoveAt( index );
37		}
38
39		public int IndexOf( string fileName )
40		{
41			for( int index = 0; index < InnerList.Count; index++ )
42				if ( this[index].Path == fileName )
43					return index;
44			return -1;
45		}
46
47		public RecentFileEntry this[int index]
48		{
49			get { return (RecentFileEntry)InnerList[index]; }
50		}
51
52		public void Clear()
53		{
54			InnerList.Clear();
55		}
56	}
57}