Skip to content

Projecting Assemblies

Ryan Davis edited this page Dec 11, 2013 · 5 revisions

There are several overloads that can be used to select the assemblies from which the Components are configured.

Method Description
FromThisAssembly() Selects the assembly that contains the current line of code.
From(params Assembly[] assemblies) From(params IEnumerable<Assembly> assemblies) Selects the specified assemblies.
From(params string[] assemblies) From(params IEnumerable<string> assemblies) Selects the specified assemblies. You can pass either file paths or assembly names.
FromAssemblyContaining<SomeType>()
FromAssemblyContaining(Type type)
Selects the assembly that contains the specified type.
FromAssembliesInPath(string path)
FromAssembliesInPath(
    string path, 
    Predicate<Assembly> filter)
Selects all assemblies from the specified path. Where a predicate is specified it is used to filter the assemblies found in the path.
FromAssembliesMatching(params string[] patterns)
FromAssembliesMatching(IEnumerable<string> patterns)
Selects all assemblies that match at least one of the specified assembly name patterns.

To project from multiple assemblies, use the Join method:

kernel.Bind(
  x => x.From("TestPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
        .SelectAllTypes()
        .Join.FromThisAssembly().SelectAllClasses()
        .BindDefaultInterface());

If Join is insufficient for your configuration needs, then run your complicated setup in multiple kernel.Bind statements.


Continue Reading: Projecting Components
Back: Overview

Clone this wiki locally