【发布时间】:2012-11-17 17:17:32
【问题描述】:
我有一个非常简单的 Ninject 绑定:
Bind<ISessionFactory>().ToMethod(x =>
{
return Fluently.Configure()
.Database(SQLiteConfiguration.Standard
.UsingFile(CreateOrGetDataFile("somefile.db")).AdoNetBatchSize(128))
.Mappings(
m => m.FluentMappings.AddFromAssembly(Assembly.Load("Sauron.Core"))
.Conventions.Add(PrimaryKey.Name.Is(p => "Id"), ForeignKey.EndsWith("Id")))
.BuildSessionFactory();
}).InSingletonScope();
我需要的是用一个参数替换 "somefile.db"。类似于
kernel.Get<ISessionFactory>("somefile.db");
我如何做到这一点?
【问题讨论】:
标签: c# .net dependency-injection ninject ninject-2