Closed mwpowellhtx closed 10 years ago
The interface of this package has totally changed from 2.0 to 3.0. Scan does not exist anymore. Either stay on 2.0 or change to the new interface.
The challenge I am having is that the interfaces don't seem to be binding. I've verified in debug mode, plugin modules are identified and loading modules, yet the plugins, i.e. implementations of design-time interfaces, are not binding through the new interface. Possibly I need to actually load those assemblies into the AppDomain as well? So either something broke between revisions or possibly the Bind interface(s) I need aren't quite right for what I want to do.
In my Kernel, I am loading the DLLs I expect, in the core service, as well as additional plugins over and above the service itself:
//Loads modules from the following locations. Load(GetFiles().Select(x => x.FullName).ToArray());
Where GetFiles() returns the assembly FileInfo paths to load. This is verified.
Then in my service module, I am binding with the following:
var executingDir = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent.FullName;
var assemblies = AppDomain.CurrentDomain.GetAssemblies()
.Where(x => x.Location.StartsWith(executingDir)).Select(x => x.Location);
Kernel.Bind(x => x.From(assemblies).SelectAllClasses().InheritedFrom
This is also verified. I am binding from only those assemblies that I want involved in the InheritedFrom operation. At this point, I also think I should be calling a fluent BindABC something-or-another, but I can't seem to find a Bind that will do what I want it to do.
Finally, when I ask Ninject for a ServiceRunner instance, which I also have bound properly:
public ServiceRunner(IEnumerable
I am receiving an enumeration with zero members. I am expecting at least one.
Note that the IServiceBase looks like this:
public abstract class AdaptableServiceBase : ServiceBase, IServiceBase { // ... }
public class MyService : AdaptableServiceBase { // ... }
In other words, I am expecting MyService to have been bound to IServiceBase, even though IServiceBase doesn't actually appear in the hierarchy until an abstract intermediate base class.
Extensions can handle this as a use-case?
Okay, okay, here we go. After dissecting the fluent API a little bit further:
Kernel.Bind(@from =>
{
@from.From(assemblies)
.SelectAllClasses()
.InheritedFrom
Then in my ctor-injection, I get the expected service(s).
Thank ye!
Hello,
I am referencing the Nuget-downloaded package and all I can seem to find are for functionality like Bind(this IKernel kernel) and so on. I see references in some of the blogs, SO, etc, that reference Scan, and so on, for functionality I might like to perform, but can't seem to find that functionality in the extensions I downloaded. Is there another branch, or a prior version(s) that might have implemented that?
Thank you...