That doesn't instantiate them, which is much harder in general. Say a Type has only one consructor, which takes an object of class A. Now you have to instantiate A. But maybe A ony has a constructor requiring a B... :-)
Hopefully, the OP doesn't want to solve the most general case, but has some specific limits he has not told us about yet. Charlie > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Chris Howie > Sent: Sunday, October 05, 2008 6:50 AM > To: Esdras Beleza > Cc: Mono mailing list > Subject: Re: [Mono-list] Instantiating all classes from a namespace > > On Mon, Sep 29, 2008 at 4:46 PM, Esdras Beleza > <[EMAIL PROTECTED]> wrote: > > The question is: how can I iterate inside a namespace > classlist, and > > create a new instance of each class of it? > > There is no cut and dried way to do this, but you can do > something like this: > > IEnumerable<Type> GetTypesInNamespace(string namespace) { > foreach (Assembly assembly in > AppDomain.CurrentDomain.GetAssemblies()) { > foreach (Type type in assembly.GetTypes()) { > if (type.Namespace == namespace) > yield return type; > } > } > } > > Or you can do something LINQy. :) > > -- > Chris Howie > http://www.chrishowie.com > http://en.wikipedia.org/wiki/User:Crazycomputers > _______________________________________________ > Mono-list maillist - [email protected] > http://lists.ximian.com/mailman/listinfo/mono-list > _______________________________________________ Mono-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-list
