PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/src/NUnit/util/RecentFilesCollection.cs

#
C# | 57 lines | 41 code | 8 blank | 8 comment | 5 complexity | 9f205549c3cf26b22174c25a8a0ba3be MD5 | raw file
Possible License(s): GPL-2.0
  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. using System;
  7. using System.Collections;
  8. namespace NUnit.Util
  9. {
  10. /// <summary>
  11. /// Summary description for RecentFilesCollection.
  12. /// </summary>
  13. public class RecentFilesCollection : ReadOnlyCollectionBase
  14. {
  15. public void Add( RecentFileEntry entry )
  16. {
  17. InnerList.Add( entry );
  18. }
  19. public void Insert( int index, RecentFileEntry entry )
  20. {
  21. InnerList.Insert( index, entry );
  22. }
  23. public void Remove( string fileName )
  24. {
  25. int index = IndexOf( fileName );
  26. if ( index != -1 )
  27. RemoveAt( index );
  28. }
  29. public void RemoveAt( int index )
  30. {
  31. InnerList.RemoveAt( index );
  32. }
  33. public int IndexOf( string fileName )
  34. {
  35. for( int index = 0; index < InnerList.Count; index++ )
  36. if ( this[index].Path == fileName )
  37. return index;
  38. return -1;
  39. }
  40. public RecentFileEntry this[int index]
  41. {
  42. get { return (RecentFileEntry)InnerList[index]; }
  43. }
  44. public void Clear()
  45. {
  46. InnerList.Clear();
  47. }
  48. }
  49. }