Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Tamás Tárnok trnktms

:octocat:
View GitHub Profile
View LockRecursionException.log
[LockRecursionException: A read lock may not be acquired with the write lock held in this mode.]
System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore(TimeoutTracker timeout) +1347
System.Threading.ReaderWriterLockSlim.TryEnterReadLock(TimeoutTracker timeout) +44
Sitecore.DependencyInjection.ServiceLocator.get_ServiceProvider() +176
Sitecore.Configuration.<>c.<.cctor>b__360_0() +9
System.Lazy`1.CreateValue() +734
System.Lazy`1.LazyInitValue() +189
Sitecore.Configuration.Settings.GetSetting(String name) +48
View SettingsUtil.cs
public static class SettingsUtil
{
// 1. Instead of Factory.GetConfigNode(customConfigNode)
public XmlNode GetConfigNode(string customConfigNode)
{
return ConfigReader.GetConfiguration().SelectSingleNode($"sitecore/{customConfigNode}");
}
// 2. Instead of Settings.GetSetting(name)
public string GetSetting(string name)
View ChildrenBlockModel.cs
namespace Discovering.Sitecore10.Models
{
public class ChildrenBlockModel
{
[SitecoreComponentField(Name = "items")]
public IEnumerable<ItemLinkField<ContentBlockModel>> Children { get; set; }
}
public class ContentBlockModel
{
View ChildrenBlock.cshtml
@model ChildrenBlockModel
@foreach (var child in Model?.Children ?? Enumerable.Empty<ItemLinkField<ContentBlockModel>>())
{
@await Html.PartialAsync("/Views/Shared/Components/SitecoreComponent/ContentBlock.cshtml", child.Fields)
}
View ChildrenBlock.cs
public class ChildrenBlock : ViewComponent
{
private readonly IViewModelBinder _viewModelBinder;
public ChildrenBlock(IViewModelBinder viewModelBinder)
{
_viewModelBinder = viewModelBinder;
}
public async Task<IViewComponentResult> InvokeAsync()
View ChildrenBlockModel.cs
namespace Discovering.Sitecore10.Models
{
public class ChildrenBlockModel
{
[SitecoreComponentField(Name = "items")]
public IEnumerable<ChildContentBlockModel> Children { get; set; }
}
public class ChildContentBlockModel
{
View LayoutServiceResponse.json
{
...
"placeholders": {
"discovering-sitecore10-main": [
{
...
"fields": {
"items": [
{
"id": "5603c106-09d8-4895-8aee-0ecfb3b69522",
View Discovering.RenderingHostCacheClear.config
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore role:require="Standalone or ContentManagement">
<RenderingHostCacheClear.Tenants>
<Tenant startPath="/sitecore/content/Discovering-Sitecore10">
<Endpoint>https://www.renderinhost1.localhost/api/outputcache/clear</Endpoint>
<Endpoint>https://www.renderinhost2.localhost/api/outputcache/clear</Endpoint>
</Tenant>
</RenderingHostCacheClear.Tenants>
<events>
View Startup.cs
namespace Discovering.Sitecore10
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
...
// Sitecore output caching
services.AddSingleton<IOutputCacheService, OutputCacheService>();
services.Configure<OutputCacheOptions>(options => options.Enabled = true);
View OutputCacheController.cs
namespace Discovering.Sitecore10.Controllers.Caching
{
public class OutputCacheController : Controller
{
private readonly IOutputCacheService _outputCacheService;
public OutputCacheController(IOutputCacheService outputCacheService)
{
_outputCacheService = outputCacheService;
}