我使用Microsoft扩展的依赖注入在Sitecore的8.2更新4螺旋框架,下面是我的代码:如何在Http Handler Sitecore中使用Microsoft.Extensions.DependencyInjection?
public class TestTextHandler : IHttpHandler
{
private readonly ITest _test;
public TestTextHandler(Test test)
{
_test = test;
}
}
public interface ITest
{
}
public class Test : ITest
{
}
public class RegisterContainer : IServicesConfigurator
{
public void Configure(IServiceCollection serviceCollection)
{
serviceCollection.AddTransient<ITest, Test>();
}
}
一个补丁文件:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<services>
<configurator type="XX.XX.RegisterContainer, XX.XX" />
</services>
</sitecore>
</configuration>
我对类型“XX得到错误构造.XX.TestTextHandler“未找到。
谢谢你,让我看看 – SKG
不是为我工作。如果你能分享你的代码,那将会很棒。 – SKG