importing messaging-2008 branch to trunk, going on.
[mono.git] / mcs / nunit20 / util / AssemblyList.cs
1 #region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
2 /************************************************************************************
3 '
4 ' Copyright  2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
5 ' Copyright  2000-2002 Philip A. Craig
6 '
7 ' This software is provided 'as-is', without any express or implied warranty. In no 
8 ' event will the authors be held liable for any damages arising from the use of this 
9 ' software.
10
11 ' Permission is granted to anyone to use this software for any purpose, including 
12 ' commercial applications, and to alter it and redistribute it freely, subject to the 
13 ' following restrictions:
14 '
15 ' 1. The origin of this software must not be misrepresented; you must not claim that 
16 ' you wrote the original software. If you use this software in a product, an 
17 ' acknowledgment (see the following) in the product documentation is required.
18 '
19 ' Portions Copyright  2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
20 ' or Copyright  2000-2002 Philip A. Craig
21 '
22 ' 2. Altered source versions must be plainly marked as such, and must not be 
23 ' misrepresented as being the original software.
24 '
25 ' 3. This notice may not be removed or altered from any source distribution.
26 '
27 '***********************************************************************************/
28 #endregion
29
30 using System;
31 using System.IO;
32 using System.Collections;
33
34 namespace NUnit.Util
35 {
36         /// <summary>
37         /// Represents a list of assemblies. It stores paths 
38         /// that are added and marks it's ProjectContainer
39         /// as dirty whenever it changes. All paths must
40         /// be added as absolute paths.
41         /// </summary>
42         public class AssemblyList : CollectionBase
43         {
44                 private ProjectConfig config;
45
46                 public AssemblyList( ProjectConfig config )
47                 {
48                         this.config = config;
49                 }
50
51                 #region Properties
52
53                 public ProjectConfig Config
54                 {
55                         get { return config; }
56                 }
57
58                 /// <summary>
59                 /// Our indexer
60                 /// </summary>
61                 public AssemblyListItem this[int index]
62                 {
63                         get { return (AssemblyListItem)List[index]; }
64 //                      set { List[index] = value; }
65                 }
66
67                 #endregion
68
69                 #region Methods
70
71                 public void Add( string assemblyPath, bool hasTests )
72                 {
73                         List.Add( new AssemblyListItem( this.config, assemblyPath, hasTests ) );
74                 }
75
76                 public void Add( string assemblyPath )
77                 {
78                         Add( assemblyPath, true );
79                 }
80
81                 public void Remove( string assemblyPath )
82                 {
83                         for( int index = 0; index < this.Count; index++ )
84                         {
85                                 if ( this[index].FullPath == assemblyPath )
86                                         RemoveAt( index );
87                         }
88                 }
89
90                 protected override void OnRemoveComplete(int index, object value)
91                 {
92                         config.IsDirty = true;
93                 }
94
95                 protected override void OnInsertComplete(int index, object value)
96                 {
97                         config.IsDirty = true;
98                 }
99                 
100                 protected override void OnSetComplete(int index, object oldValue, object newValue )
101                 {
102                         config.IsDirty = true;
103                 }
104
105                 #endregion
106         }
107 }