Skip to content

Commit

Permalink
Merge branch 'pr/3'
Browse files Browse the repository at this point in the history
Conflicts:
	NitroNet.Sitecore.CastleWindsorModules/NitroNet.Sitecore.CastleWindsorModules.csproj
	NitroNet.Sitecore.UnityModules/NitroNet.Sitecore.UnityModules.csproj
  • Loading branch information
NaibafCH committed Jun 14, 2016
2 parents 757a588 + 580b5cb commit df46ff0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
Expand Up @@ -38,6 +38,10 @@
<HintPath>..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Sitecore.Kernel, Version=8.0.5193.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\Sitecore.Kernel.dll</HintPath>
</Reference>
<Reference Include="Sitecore.Mvc">
<HintPath>..\Libs\Sitecore.Mvc.dll</HintPath>
</Reference>
Expand Down
Expand Up @@ -5,6 +5,8 @@
using NitroNet.Sitecore.Rendering;
using NitroNet.ViewEngine.TemplateHandler;
using NitroNet.ViewEngine.TemplateHandler.Grid;
using Sitecore;
using Sitecore.Data;
using Sitecore.Mvc.Common;
using Veil;

Expand All @@ -18,6 +20,7 @@ public void Configure(IWindsorContainer container)
container.Register(Component.For<ISitecoreRenderingRepository>().ImplementedBy<SitecoreRenderingRepository>());
container.Register(Component.For<ISitecoreCacheManager>().ImplementedBy<SitecoreCacheManager>());
container.Register(Component.For<INitroTemplateHandlerFactory>().ImplementedBy<SitecoreMvcNitroTemplateHandlerFactory>());
container.Register(Component.For<Database>().UsingFactoryMethod(() => Context.Database));
}
}
}
Expand Up @@ -64,6 +64,10 @@
<HintPath>..\packages\Newtonsoft.Json.Schema.1.0.8\lib\net45\Newtonsoft.Json.Schema.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Sitecore.Kernel, Version=8.0.5193.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\Sitecore.Kernel.dll</HintPath>
</Reference>
<Reference Include="Sitecore.Mvc">
<HintPath>..\Libs\Sitecore.Mvc.dll</HintPath>
</Reference>
Expand Down
5 changes: 4 additions & 1 deletion NitroNet.Sitecore.UnityModules/SitecoreUnityModule.cs
Expand Up @@ -4,6 +4,8 @@
using NitroNet.UnityModules;
using NitroNet.ViewEngine.TemplateHandler;
using NitroNet.ViewEngine.TemplateHandler.Grid;
using Sitecore;
using Sitecore.Data;
using Sitecore.Mvc.Common;
using Veil;

Expand All @@ -19,6 +21,7 @@ public void Configure(IUnityContainer container)
container.RegisterType<ISitecoreCacheManager, SitecoreCacheManager>(new ContainerControlledLifetimeManager());
container.RegisterType<INitroTemplateHandlerFactory, SitecoreMvcNitroTemplateHandlerFactory>(
new ContainerControlledLifetimeManager());
container.RegisterType<Database>(new InjectionFactory(u => Context.Database));
}
}
}
}
7 changes: 5 additions & 2 deletions NitroNet.Sitecore/Rendering/SitecoreRenderingRepository.cs
@@ -1,18 +1,21 @@
using System;
using System.Collections.Generic;
using NitroNet.Sitecore.Caching;
using Sitecore.Data;
using SC = Sitecore;

namespace NitroNet.Sitecore.Rendering
{
public class SitecoreRenderingRepository : ISitecoreRenderingRepository
{
private readonly Database _contextDatabase;
public const string ControllerRenderingId = "{2A3E91A0-7987-44B5-AB34-35C2D9DE83B9}";
public const string SitecoreRenderingCache = "NitroNet.SitecoreRenderings";
private readonly ISitecoreCache _cache;

public SitecoreRenderingRepository(ISitecoreCacheManager cacheManager)
public SitecoreRenderingRepository(ISitecoreCacheManager cacheManager, Database contextDatabase)
{
_contextDatabase = contextDatabase;
_cache = cacheManager.Get(SitecoreRenderingCache);
}

Expand All @@ -24,7 +27,7 @@ private static string GetCacheKey()
private IDictionary<string, string> GetAllRenderings()
{
var allRenderings = new Dictionary<string, string>();
var layoutItem = SC.Context.Database.GetItem(SC.ItemIDs.LayoutRoot);
var layoutItem = _contextDatabase.GetItem(SC.ItemIDs.LayoutRoot);

if (layoutItem != null)
{
Expand Down

0 comments on commit df46ff0

Please sign in to comment.