Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
public static class GlassMapperScCustom
{
public static IDependencyResolver CreateResolver(){
BoC.Persistence.SitecoreGlass.Initialize.InitBoc.Start();
global::BoC.Persistence.SitecoreGlass.Initialize.InitBoc.Start();

var config = new Glass.Mapper.Sc.Config();
var config = new global::Glass.Mapper.Sc.Config();

var resolver = new DependencyResolver(config);
//trigger addtypes
Expand All @@ -43,13 +43,13 @@
*
*/

return IoC.Resolver.ResolveAll<IConfigurationLoader>().ToArray();
return global::BoC.InversionOfControl.IoC.Resolver.ResolveAll<IConfigurationLoader>().ToArray();
}
public static void PostLoad(){
//Set config property to true in Glass.Mapper.Sc.CodeFirst.config to enable codefirst
if (!global::Sitecore.Configuration.Settings.GetBoolSetting("Glass.CodeFirst", false)) return;

var dbs = Sitecore.Configuration.Factory.GetDatabases();
var dbs = global::Sitecore.Configuration.Factory.GetDatabases();
foreach (var db in dbs)
{
var provider = db.GetDataProviders().FirstOrDefault(x => x is GlassDataProvider) as GlassDataProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,30 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Deployment">
<HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -113,6 +137,10 @@
<Compile Include="DataContext\SitecoreDataContextDatabaseProvider.cs" />
<Compile Include="ContextDatabaseProvider.cs" />
<Compile Include="DefaultSetupTasks\EnableProfiling.cs" />
<Compile Include="DefaultSetupTasks\RegisterValueProvider.cs">
<SubType>
</SubType>
</Compile>
<Compile Include="DefaultSetupTasks\RegisterConfigLoader.cs" />
<Compile Include="GlassConfig\AppDomainHelperConfigLoader.cs" />
<Compile Include="FixedSearchContext.cs" />
Expand All @@ -128,6 +156,7 @@
<Compile Include="Models\ISearchable.cs" />
<Compile Include="Models\ISitecoreItem.cs" />
<Compile Include="Models\SitecoreItem.cs" />
<Compile Include="TemplateParametersValueProviderFactory.cs" />
<Compile Include="Profiling\SitecorePerformanceProfiler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SitecoreRepository.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
<copyright>Copyright 2014</copyright>
<tags>BoC,Persistence,Glass,Mapper,ORM,Repository,Sitecore</tags>
<dependencies>
<dependency id="BoC" version="4.0.0" />
<dependency id="Microsoft.AspNet.Mvc" version="5.2.3" />
<dependency id="BoC" version="4.0.1" />
<dependency id="BoC.Glass.Mapper.Sc" version="4.0.0" />
<dependency id="BoC.Glass.Mapper.Sc.ContentSearch.LuceneProvider" version="4.0.0" />
<dependency id="Castle.Core" version="3.3.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public CultureInfo GetCultureInfo()
{
return ((SitecoreDataContext) OuterDataContext).GetCultureInfo();
}
return Context.Culture;
return Context.Language.CultureInfo;
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Linq;
using System.Web.Mvc;
using BoC.Tasks;

namespace BoC.Persistence.SitecoreGlass.DefaultSetupTasks
{
public class RegisterValueProvider : IBootstrapperTask
{
public void Execute()
{
var index = ValueProviderFactories.Factories.FirstOrDefault(f => f is ChildActionValueProviderFactory);
if (index != null)
{
ValueProviderFactories.Factories.Insert(ValueProviderFactories.Factories.IndexOf(index) + 1, new ParametersTemplateValueProviderFactory());
}
else
{
ValueProviderFactories.Factories.Add(new ParametersTemplateValueProviderFactory());
}
}
}
}
4 changes: 2 additions & 2 deletions Src/Commons.Persistence.Sitecore/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.2.0")]
[assembly: AssemblyFileVersion("4.0.2.0")]
[assembly: AssemblyVersion("4.0.7.0")]
[assembly: AssemblyFileVersion("4.0.7.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.Globalization;
using System.Reflection;
using System.Web.Mvc;
using Glass.Mapper.Sc;
using Sitecore.Mvc.Presentation;

namespace BoC.Persistence.SitecoreGlass
{
public class ParametersTemplateValueProviderFactory : ValueProviderFactory
{
public override IValueProvider GetValueProvider(ControllerContext controllerContext)
{
return new ParametersTemplateValueProvider();
}

private class ParametersTemplateValueProvider : IValueProvider
{
public bool ContainsPrefix(string prefix)
{
return "renderingParameters".Equals(prefix, StringComparison.OrdinalIgnoreCase);
}

public ValueProviderResult GetValue(string key)
{
var context = RenderingContext.CurrentOrNull;
if (context == null) return null;

var keyval = key.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
var prefix = keyval[0];
switch (prefix.ToLowerInvariant())
{
case "renderingparameters":
if (RenderingContext.CurrentOrNull == null)
return new ValueProviderResult(null, "renderingParameters", CultureInfo.CurrentCulture);
return new ParametersTemplateValueProviderResult(RenderingContext.CurrentOrNull.Rendering[GlassHtml.Parameters], CultureInfo.CurrentCulture);
default:
return null;
}
}

}
}

internal class ParametersTemplateValueProviderResult : ValueProviderResult
{
private readonly string _parameters;

public ParametersTemplateValueProviderResult(string parameters, CultureInfo cultureInfo): base(parameters, parameters, cultureInfo)
{
_parameters = parameters;
}

static MethodInfo method = typeof(GlassHtml).GetMethod("GetRenderingParameters", BindingFlags.Instance | BindingFlags.Public, null, new[] { typeof(string) }, null);
public override object ConvertTo(Type type, CultureInfo culture)
{
if (String.IsNullOrEmpty(_parameters))
return null;

var glassHtml = new GlassHtml(SitecoreContext.GetFromHttpContext());
var genericMethod = method.MakeGenericMethod(type);
return genericMethod.Invoke(glassHtml, new object[]{_parameters}) ?? base.ConvertTo(type, culture);
}
}
}
3 changes: 3 additions & 0 deletions Src/Commons.Persistence.Sitecore/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<package id="BoC.Glass.Mapper.Sc.ContentSearch.LuceneProvider" version="4.0.0" targetFramework="net45" />
<package id="Castle.Core" version="3.3.3" targetFramework="net45" />
<package id="Lucene.Net" version="3.0.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.Bcl.Immutable" version="1.0.34" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="ReadOnlyCollectionInterfaces" version="1.0.0" targetFramework="net45" />
Expand Down
16 changes: 8 additions & 8 deletions Src/Commons.Persistence.UmbracoGlass/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BoC.Persistence.UmbracoGlass")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("BoC.Sitecore.Mvc")]
[assembly: AssemblyDescription("Mvc stuff for sitecore")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BoC.Persistence.UmbracoGlass")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyCompany("Chris van de Steeg")]
[assembly: AssemblyProduct("BoC.Sitecore.Mvc")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -20,7 +20,7 @@
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("679867b2-0cc4-493a-85ca-d25266a6702f")]
[assembly: Guid("13d89bef-9ca9-46eb-899c-dda310cddb55")]

// Version information for an assembly consists of the following four values:
//
Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyVersion("4.0.3.0")]
[assembly: AssemblyFileVersion("4.0.3.0")]
4 changes: 2 additions & 2 deletions Src/Commons.Sitecore.Mvc/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyVersion("4.0.3.0")]
[assembly: AssemblyFileVersion("4.0.3.0")]
6 changes: 6 additions & 0 deletions Src/Commons.Sitecore.Mvc/SitecoreValueProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public bool ContainsPrefix(string prefix)
return
"contextItem".Equals(prefix, StringComparison.OrdinalIgnoreCase)
|| "renderingItem".Equals(prefix, StringComparison.OrdinalIgnoreCase)
|| "pageContextItem".Equals(prefix, StringComparison.OrdinalIgnoreCase)
|| "dataSource".Equals(prefix, StringComparison.OrdinalIgnoreCase);
}

Expand All @@ -43,6 +44,11 @@ public ValueProviderResult GetValue(string key)
return new ValueProviderResult(null, "contextitem", CultureInfo.CurrentCulture);
return GetValueResult(context.ContextItem, property);

case "pagecontextitem":
if (context.PageContext == null || context.PageContext.Item == null)
return new ValueProviderResult(null, "contextitem", CultureInfo.CurrentCulture);
return GetValueResult(context.PageContext.Item, property);

case "renderingitem":
if (context.Rendering == null || context.Rendering.RenderingItem == null)
return new ValueProviderResult(null, "renderingitem", CultureInfo.CurrentCulture);;
Expand Down
53 changes: 30 additions & 23 deletions Src/Commons/Helpers/AppDomainHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,29 +96,11 @@ private void EnsureLoaded()
var filters = FileFilter.Split('|');
foreach (var path in paths)
{
try
{
loadedAssemblies.AddRange(
filters.SelectMany(s => Directory.GetFiles(path, s)).Select(Assembly.LoadFrom));
Loaded = true;
}
// Files should always exists but don't blow up here if they don't
catch (FileNotFoundException)
{
}
// File was found but could not be loaded
catch (FileLoadException)
{
}
// Dlls that contain native code are not loaded, but do not invalidate the Directory
catch (BadImageFormatException)
{
}
// Dlls that have missing Managed dependencies are not loaded, but do not invalidate the Directory
catch (ReflectionTypeLoadException)
{
}

loadedAssemblies.AddRange(
filters.SelectMany(s => Directory.GetFiles(path, s))
.Select(TryLoadAssembly)
.Where(it => it != null ));
Loaded = true;
}

}
Expand All @@ -127,6 +109,31 @@ private void EnsureLoaded()
}


private Assembly TryLoadAssembly(String path)
{
try
{
return Assembly.LoadFrom(path);
}
// Files should always exists but don't blow up here if they don't
catch (FileNotFoundException)
{
}
// File was found but could not be loaded
catch (FileLoadException)
{
}
// Dlls that contain native code are not loaded, but do not invalidate the Directory
catch (BadImageFormatException)
{
}
// Dlls that have missing Managed dependencies are not loaded, but do not invalidate the Directory
catch (ReflectionTypeLoadException)
{
}

return null;
}
/// <summary>
/// Releases the unmanaged resources used by the <see cref="AppDomainHelper"/> and
/// optionally releases the managed resources.
Expand Down
16 changes: 12 additions & 4 deletions Src/Commons/Initializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,18 @@ public static void Execute(IDependencyResolver dependencyResolver, params IAppDo
return;
lock (initializer_lock)
{
if (Executed)
return;
IoC.InitializeWith(dependencyResolver, appDomainHelpers);
new Bootstrapper(dependencyResolver, appDomainHelpers).Run();
if (appDomainHelpers != null)
{
foreach (var appDomainHelper in appDomainHelpers)
{
dependencyResolver.RegisterInstance<IAppDomainHelper>(appDomainHelper);
}
}

IoC.InitializeWith(dependencyResolver);
var bootstrapper = dependencyResolver.Resolve<Bootstrapper>();
if (bootstrapper != null)
bootstrapper.Run();
Executed = true;
}

Expand Down