6
私はNinjectに問題があります。Ninject + ASP.NET MVC + InRequestScope
マイ結合規則:
のSQLServer、ISphinxQLServerとIMySQLServerがある
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>());
:
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;
}
}
私は私のasp.net MVCのサイトに、各ユーザー要求が作成する必要単一のSQLServer、単一のISQLLogger、および単一のDatabaseConnectionsが含まれます。しかし、私の解決策は動作しません。私は間違って何をしていますか? =(
。ありがとう、これは同様の問題で私を助けた。 –