我使用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