tamerz
tamerz

Reputation: 13

Loading type from new assembly using structuremap.net

I'm playing around with structuremap.net and what I'm trying to do (I'm not sure if it possible or not) is loading type implementing specific interface and this type exist in assembly that's not refrence in my application, for example i want to drop new assembly in the application directory and configure the IOC container to load , currently i'm not using a configuration file i'm just testing the concept :)

Thanks in advance

Upvotes: 1

Views: 277

Answers (1)

PHeiberg
PHeiberg

Reputation: 29811

It's possible to scan all Assemblies in the application directory:

ObjectFactory.Initialize(
    c => c.Scan( s => 
    {
        s.AssembliesFromBaseDirectory();
        s.AddAllTypesOf<IMyInterface>().NameBy(type => type.Name);
    })
);

or specific assemblies in a specific folder:

ObjectFactory.Initialize(
    c => c.Scan( s => 
    {
        s.AssembliesFromPath("thePath", assembly => assembly.GetName()
            .Name.Contains("Extension"));
        s.AddAllTypesOf<IMyInterface>();
    })
);

Upvotes: 1

Related Questions