Hi. I'm trying to iterate through all components and for those who implements ISupportsOpen allow to open a project. The problem is when the anonymous method is called, then the component variable is always the same element (as coming from the outer scope from IEnumerable)
foreach (ISupportsOpen component in something.Site.Container.Components.OfType<ISupportsOpen>())
{
MyClass m = new MyClass();
m.Called += new EventHandler(delegate(object sender, EventArgs e)
{
if (component.CanOpenProject(..)) component.OpenProject(..);
});
itemsList.Add(m);
}
How should it be solved, please?