1 // ****************************************************************
\r
2 // This is free software licensed under the NUnit license. You
\r
3 // may obtain a copy of the license as well as information regarding
\r
4 // copyright ownership at http://nunit.org/?p=license&r=2.4.
\r
5 // ****************************************************************
\r
8 using System.Collections;
\r
10 namespace NUnit.Util
\r
13 /// Summary description for ProjectConfigCollection.
\r
15 public class ProjectConfigCollection : CollectionBase
\r
17 protected NUnitProject project;
\r
19 public ProjectConfigCollection( NUnitProject project )
\r
21 this.project = project;
\r
25 public ProjectConfig this[int index]
\r
27 get { return (ProjectConfig)InnerList[index]; }
\r
30 public ProjectConfig this[string name]
\r
34 int index = IndexOf( name );
\r
35 return index >= 0 ? (ProjectConfig)InnerList[index]: null;
\r
41 public void Add( ProjectConfig config )
\r
44 config.Project = this.project;
\r
45 config.Changed += new EventHandler(config_Changed);
\r
48 public void Add( string name )
\r
50 Add( new ProjectConfig( name ) );
\r
53 public void Remove( string name )
\r
55 int index = IndexOf( name );
\r
62 private int IndexOf( string name )
\r
64 for( int index = 0; index < InnerList.Count; index++ )
\r
66 ProjectConfig config = (ProjectConfig)InnerList[index];
\r
67 if( config.Name == name )
\r
74 public bool Contains( ProjectConfig config )
\r
76 return InnerList.Contains( config );
\r
79 public bool Contains( string name )
\r
81 return IndexOf( name ) >= 0;
\r
84 protected override void OnRemoveComplete( int index, object obj )
\r
86 ProjectConfig config = obj as ProjectConfig;
\r
87 this.project.OnProjectChange( ProjectChangeType.RemoveConfig, config.Name );
\r
90 protected override void OnInsertComplete( int index, object obj )
\r
92 ProjectConfig config = obj as ProjectConfig;
\r
93 project.OnProjectChange( ProjectChangeType.AddConfig, config.Name );
\r
96 private void config_Changed(object sender, EventArgs e)
\r
98 ProjectConfig config = sender as ProjectConfig;
\r
99 project.OnProjectChange( ProjectChangeType.UpdateConfig, config.Name );
\r