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