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 // ****************************************************************
8 using System
.Collections
;
13 /// Summary description for ProjectConfigCollection.
15 public class ProjectConfigCollection
: CollectionBase
17 protected NUnitProject project
;
19 public ProjectConfigCollection( NUnitProject project
)
21 this.project
= project
;
25 public ProjectConfig
this[int index
]
27 get { return (ProjectConfig)InnerList[index]; }
30 public ProjectConfig
this[string name
]
34 int index
= IndexOf( name
);
35 return index
>= 0 ? (ProjectConfig
)InnerList
[index
]: null;
41 public void Add( ProjectConfig 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
);
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
)
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
);