I'm registering components with the following code:
StandardKernel kernel = new StandardKernel();
string currentDirectory = Path.GetDirectoryName(GetType().Assembly.Location)
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
if (!Path.GetDirectoryName(assembly.Location).Equals(currentDirectory))
continue;
foreach (var type in assembly.GetTypes())
{
if (!type.IsComponent())
continue;
foreach (var @interface in type.GetInterfaces())
kernel.Bind(@interface).To(type).InSingletonScope();
}
}
Then I have a class which implements two interfaces:
class StandardConsole : IStartable, IConsumer<ConsoleCommand>
If I Resolve IStartable I get one instance, if I Resolve IConsumer I get another. How do I get the same instance for both interfaces?
Please don't reply if you haven't used autofac or ninject
I've tried with both ninject and autofac :(