tidying that up a bit....

foreach(var asm in AssembliesInFolder("plugins"))
{
     
container.Register(AllTypes.Of<IPlugin>().FromAssembly(asm).WithService.FromInterface());
}

// :
// :
using System.IO;
IEnumerable<Assembly> AssembliesInFolder(string folder)
{
    string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, folder);
    foreach(var asmpath in Directory.GetFiles(path))
          yield return Assembly.LoadFile(asmpath);
}



On Mon, Aug 3, 2009 at 10:44 AM, DoniG<[email protected]> wrote:
>
> Something like this will register all assemblies in a directory:
>
>            string[] dlls = System.IO.Directory.GetFiles
> (AppDomain.CurrentDomain.BaseDirectory + "/plugins", "*.dll");
>            foreach(string asmpath in dlls)
>            {
>                container.Register(AllTypes.Of<IPlugin>()
>                                       .FromAssembly(Assembly.LoadFile
> (asmpath)).WithService.FromInterface());
>            }
>
> >
>



-- 
Truth,
    James

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to