J'ai un problème avec le Ninject.Ninject + ASP.NET MVC + InRequestScope
Mes règles contraignantes:
this.Bind<ISphinxQLServer>().To<SQLServer>();
this.Bind<IMySQLServer>().To<SQLServer>();
this.Bind<ISQLLogger>().To<StandardSQLLogger>()
.InRequestScope();
this.Bind<DatabaseConnections>()
.ToMethod(x => ConnectionFactory.GetConnections())
.InRequestScope();
this.Bind<SQLServer>().ToSelf()
.InRequestScope()
.WithConstructorArgument("connections", Kernel.Get<DatabaseConnections>())
.WithConstructorArgument("logger", Kernel.Get<ISQLLogger>());
Où
SQLServer, ISphinxQLServer et IMySQLServer sont:
public class SQLServer: ISphinxQLServer, IMySQLServer
{
public DatabaseConnections Connections { get; internal set; }
public ISQLLogger Logger { get; internal set; }
public SQLServer(DatabaseConnections connections)
{
this.Connections = connections;
}
public SQLServer(DatabaseConnections connections, ISQLLogger logger)
{
this.Connections = connections;
this.Logger = logger;
}
}
Je veux que chaque utilisateur demande à mon asp.net crée le site mvc un seul SQLServer, un seul ISQLLogger et un seul DatabaseConnections. Mais ma solution ne fonctionne pas. Qu'est-ce que je fais mal? . = (
Merci, cela m'a aidé avec un problème similaire. –