Permalink
Browse files

Merge branch 'develop' into feature/Caching

Conflicts:
	Sites/Sitecore/Glass.Mapper.Sites.Sc/Glass.Mapper.Sites.Sc.csproj
	Source/Glass.Mapper.Sc/Glass.Mapper.Sc.csproj
	Source/Glass.Mapper/AbstractService.cs
	Source/Glass.Mapper/Glass.Mapper.csproj

Also fixed some other issues to get source to compile
  • Loading branch information...
2 parents 3df5a99 + feaa5fe commit a52d263f2f81206223dd7b3e517e83aeacb6f0d2 @gravypower gravypower committed Jan 15, 2013
Showing with 838 additions and 180 deletions.
  1. +21 −0 Sites/Sitecore/Glass.Mapper.Sites.Sc/Glass.Mapper.Sites.Sc.csproj
  2. +17 −0 Sites/Sitecore/Glass.Mapper.Sites.Sc/Models/ModelBase.cs
  3. +3 −0 Sites/Sitecore/Glass.Mapper.Sites.Sc/layouts/TestSub.ascx
  4. +31 −0 Sites/Sitecore/Glass.Mapper.Sites.Sc/layouts/TestSub.ascx.cs
  5. +33 −0 Sites/Sitecore/Glass.Mapper.Sites.Sc/layouts/TestSub.ascx.designer.cs
  6. +1 −1 Source/Glass.Mapper.Sc/DataMappers/AbstractSitecoreFieldMapper.cs
  7. +4 −1 Source/Glass.Mapper.Sc/DataMappers/SitecoreFieldStringMapper.cs
  8. +3 −2 Source/Glass.Mapper.Sc/DataMappers/SitecoreIdMapper.cs
  9. +1 −1 Source/Glass.Mapper.Sc/DataMappers/SitecoreLinkedMapper.cs
  10. +3 −1 Source/Glass.Mapper.Sc/Glass.Mapper.Sc.csproj
  11. +89 −0 Source/Glass.Mapper.Sc/ISitecoreContext.cs
  12. +81 −0 Source/Glass.Mapper.Sc/SitecoreContext.cs
  13. +212 −13 Source/Glass.Mapper.Sc/SitecoreService.cs
  14. +1 −1 Source/Glass.Mapper.Sc/Utilities.cs
  15. +54 −24 Source/Glass.Mapper/AbstractService.cs
  16. +2 −0 Source/Glass.Mapper/AbstractTypeCreationContext.cs
  17. +1 −1 Source/Glass.Mapper/Configuration/AbstractTypeConfiguration.cs
  18. +16 −1 Source/Glass.Mapper/Configuration/Attributes/AttributeConfigurationLoader.cs
  19. +5 −1 Source/Glass.Mapper/Glass.Mapper.csproj
  20. +9 −0 Source/Glass.Mapper/Pipelines/AbstractPipelineRunner.cs
  21. +9 −13 Source/Glass.Mapper/Pipelines/ObjectConstruction/Tasks/CreateConcrete/CreateConcreteTask.cs
  22. +13 −0 Source/Glass.Mapper/Profilers/IPerformanceProfiler.cs
  23. +18 −0 Source/Glass.Mapper/Profilers/NullProfiler.cs
  24. +34 −0 Source/Glass.Mapper/Profilers/SimpleProfiler.cs
  25. +9 −4 Source/Glass.Mapper/Utilities.cs
  26. +6 −28 Tests/Integration Tests/Sitecore/Glass.Mapper.Sc.Integration/Glass.Mapper.Sc.Integration.csproj
  27. +152 −55 Tests/Integration Tests/Sitecore/Glass.Mapper.Sc.Integration/PerformanceTests.cs
  28. +2 −16 Tests/Unit Tests/Glass.Mapper.Sc.Tests/Glass.Mapper.Sc.Tests.csproj
  29. +1 −1 Tests/Unit Tests/Glass.Mapper.Tests/AbstractServiceFixture.cs
  30. +7 −7 Tests/Unit Tests/Glass.Mapper.Tests/UtilitiesFixture.cs
  31. +0 −9 Tests/Unit Tests/Glass.Mapper.Umb.Tests/Glass.Mapper.Umb.Tests.csproj
@@ -189,6 +189,7 @@
<Content Include="App_Config\XamlSharp.config" />
<None Include="default.htm.sitedown" />
<Content Include="Design.config" />
+ <Content Include="layouts\TestSub.ascx" />
<Content Include="sitecore_files\Web.config" />
<Content Include="Web.config" />
<None Include="Web.config.MVC" />
@@ -217,6 +218,26 @@
<Content Include="xsl\sample rendering.xslt" />
<Content Include="xsl\system\WebEdit\Hidden Rendering.xslt" />
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="layouts\TestSub.ascx.cs">
+ <DependentUpon>TestSub.ascx</DependentUpon>
+ <SubType>ASPXCodeBehind</SubType>
+ </Compile>
+ <Compile Include="layouts\TestSub.ascx.designer.cs">
+ <DependentUpon>TestSub.ascx</DependentUpon>
+ </Compile>
+ <Compile Include="Models\ModelBase.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\Source\Glass.Mapper.Sc\Glass.Mapper.Sc.csproj">
+ <Project>{0B8E0B06-46B8-4794-862F-73B391F8B1A1}</Project>
+ <Name>Glass.Mapper.Sc</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\Source\Glass.Mapper\Glass.Mapper.csproj">
+ <Project>{566109ED-A88A-467E-BDDB-BBF7F831A006}</Project>
+ <Name>Glass.Mapper</Name>
+ </ProjectReference>
+ </ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Glass.Mapper.Sc.Configuration.Attributes;
+
+namespace Glass.Mapper.Sites.Sc.Models
+{
+ [SitecoreType]
+ public class ModelBase
+ {
+ [SitecoreField]
+ public virtual string Title { get; set; }
+ [SitecoreField]
+ public virtual string Text { get; set; }
+ }
+}
@@ -0,0 +1,3 @@
+<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TestSub.ascx.cs" Inherits="Glass.Mapper.Sites.Sc.layouts.TestSub" %>
+<asp:Literal runat="server" ID="Title"></asp:Literal>
+<asp:Literal runat="server" ID="Text"></asp:Literal>
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using Glass.Mapper.Sc;
+using Glass.Mapper.Sc.Configuration.Attributes;
+using Glass.Mapper.Sc.Integration;
+using Glass.Mapper.Sites.Sc.Models;
+
+namespace Glass.Mapper.Sites.Sc.layouts
+{
+ public partial class TestSub : System.Web.UI.UserControl
+ {
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ var context = Glass.Mapper.Context.Create(new GlassConfig());
+ context.Load(new SitecoreAttributeConfigurationLoader(
+ "Glass.Mapper.Sites.Sc"
+ ));
+
+ SitecoreService service = new SitecoreService(Sitecore.Context.Database);
+ var item = service.GetItem<ModelBase>(Sitecore.Context.Item.ID.Guid);
+
+ Text.Text = item.Text;
+ Title.Text = item.Title;
+
+ }
+ }
+}
@@ -0,0 +1,33 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Glass.Mapper.Sites.Sc.layouts {
+
+
+ public partial class TestSub {
+
+ /// <summary>
+ /// Title control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.Literal Title;
+
+ /// <summary>
+ /// Text control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.Literal Text;
+ }
+}
@@ -19,7 +19,7 @@ public AbstractSitecoreFieldMapper(params Type [] typesHandled)
public override void MapToCms(AbstractDataMappingContext mappingContext)
{
var scConfig = Configuration as SitecoreFieldConfiguration;
- var scContext = mappingContext as SitecoreDataMappingContext;
+ var scContext = mappingContext as SitecoreDataMappingContext ;
var field = Utilities.GetField(scContext.Item, scConfig.FieldId, scConfig.FieldName);
object value = Configuration.PropertyInfo.GetValue(mappingContext.Object, null);
@@ -18,7 +18,10 @@ public override object GetField(Sitecore.Data.Fields.Field field, SitecoreFieldC
if (field == null)
return string.Empty;
- if (field.Type.StartsWith("Rich Text") && config.Setting != SitecoreFieldSettings.RichTextRaw)
+ if (config.Setting != SitecoreFieldSettings.RichTextRaw)
+ return field.Value;
+
+ if (field.Type.StartsWith("Rich Text"))
{
FieldRenderer renderer = new FieldRenderer();
renderer.Item = field.Item;
@@ -22,10 +22,11 @@ public override void MapToCms(AbstractDataMappingContext mappingContext)
public override object MapToProperty(AbstractDataMappingContext mappingContext)
{
- SitecoreDataMappingContext context = mappingContext as SitecoreDataMappingContext;
+
+ SitecoreDataMappingContext context = (SitecoreDataMappingContext)mappingContext;
var item = context.Item;
- var scConfig = Configuration as SitecoreIdConfiguration;
+ var scConfig = Configuration;
if (scConfig.PropertyInfo.PropertyType == typeof(Guid))
return item.ID.Guid;
@@ -33,7 +33,7 @@ public override object MapToProperty(AbstractDataMappingContext mappingContext)
var item = scContext.Item;
//ME - i am not sure this is correct but there is an odd behaviour of references
- // lanugauges come back as invariant, going with default language in this scenario
+ // languges come back as invariant, going with default language in this scenario
var references = new Func<IEnumerable<Item>>(() =>{
var itemLinks = global::Sitecore.Configuration.Factory.GetLinkDatabase().GetReferences(item);
var items = itemLinks.Select(x => x.GetTargetItem());
@@ -132,10 +132,12 @@
<Compile Include="Fields\TriState.cs" />
<Compile Include="GlassConfig.cs" />
<Compile Include="Global.cs" />
+ <Compile Include="ISitecoreContext.cs" />
<Compile Include="ISitecoreService.cs" />
<Compile Include="ItemEditing.cs" />
<Compile Include="LazyItemEnumerable.cs" />
<Compile Include="Pipelines\SitecorePipelineArg.cs" />
+ <Compile Include="SitecoreContext.cs" />
<Compile Include="SitecoreDataMappingContext.cs" />
<Compile Include="SitecoreTypeCreationContext.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -172,4 +174,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Glass.Mapper.Sc
+{
+ public interface ISitecoreContext : ISitecoreService
+ {
+ /// <summary>
+ /// Retrieves the current item as the specified type
+ /// </summary>
+ /// <typeparam name="T">The type to return.</typeparam>
+ /// <returns>The current item as the specified type</returns>
+ T GetCurrentItem<T>(bool isLazy = false, bool inferType = false) where T : class;
+
+ /// <summary>
+ /// Retrieves the current item as the specified type
+ /// </summary>
+ /// <typeparam name="T">The type to return the Sitecore item as</typeparam>
+ /// <typeparam name="K">The type of the first constructor parameter</typeparam>
+ /// <param name="param1">The value of the first parameter of the constructor</param>
+ /// <returns>The Sitecore item as the specified type</returns>
+ T GetCurrentItem<T, K>(K param1, bool isLazy = false, bool inferType = false) where T : class;
+
+ /// <summary>
+ /// Retrieves the current item as the specified type
+ /// </summary>
+ /// <typeparam name="T">The type to return the Sitecore item as</typeparam>
+ /// <typeparam name="K">The type of the first constructor parameter</typeparam>
+ /// <typeparam name="L">The type of the second constructor parameter</typeparam>
+ /// <param name="param1">The value of the first parameter of the constructor</param>
+ /// <param name="param2">The value of the second parameter of the constructor</param>
+ /// <returns>The Sitecore item as the specified type</returns>
+ T GetCurrentItem<T, K, L>(K param1, L param2, bool isLazy = false, bool inferType = false) where T : class;
+
+ /// <summary>
+ /// Retrieves the current item as the specified type
+ /// </summary>
+ /// <typeparam name="T">The type to return the Sitecore item as</typeparam>
+ /// <typeparam name="K">The type of the first constructor parameter</typeparam>
+ /// <typeparam name="L">The type of the second constructor parameter</typeparam>
+ /// <typeparam name="M">The type of the third constructor parameter</typeparam>
+ /// <param name="param1">The value of the first parameter of the constructor</param>
+ /// <param name="param2">The value of the second parameter of the constructor</param>
+ /// <param name="param3">The value of the third parameter of the constructor</param>
+ /// <returns>The Sitecore item as the specified type</returns>
+ T GetCurrentItem<T, K, L, M>(K param1, L param2, M param3, bool isLazy = false, bool inferType = false) where T : class;
+
+ /// <summary>
+ /// Retrieves the current item as the specified type
+ /// </summary>
+ /// <typeparam name="T">The type to return the Sitecore item as</typeparam>
+ /// <typeparam name="K">The type of the first constructor parameter</typeparam>
+ /// <typeparam name="L">The type of the second constructor parameter</typeparam>
+ /// <typeparam name="M">The type of the third constructor parameter</typeparam>
+ /// <typeparam name="N">The type of the fourth constructor parameter</typeparam>
+ /// <param name="param1">The value of the first parameter of the constructor</param>
+ /// <param name="param2">The value of the second parameter of the constructor</param>
+ /// <param name="param3">The value of the third parameter of the constructor</param>
+ /// <param name="param4">The value of the fourth parameter of the constructor</param>
+ /// <returns>The Sitecore item as the specified type</returns>
+ T GetCurrentItem<T, K, L, M, N>(K param1, L param2, M param3, N param4, bool isLazy = false, bool inferType = false) where T : class;
+
+ /// <summary>
+ /// Retrieves the current item as the specified type
+ /// </summary>
+ /// <param name="type">The type to return.</param>
+ /// <returns>The current item as the specified type</returns>
+ object GetCurrentItem(Type type, bool isLazy = false, bool inferType = false);
+
+ /// <summary>
+ /// Performs a query relative to the current item
+ /// </summary>
+ /// <typeparam name="T">The type to cast classes to</typeparam>
+ /// <returns></returns>
+ IEnumerable<T> QueryRelative<T>(string query, bool isLazy = false, bool inferType = false) where T : class;
+
+ /// <summary>
+ /// Performs a query relative to the current item
+ /// </summary>
+ /// <typeparam name="T">The type to cast classes to</typeparam>
+ /// <returns></returns>
+ T QuerySingleRelative<T>(string query, bool isLazy = false, bool inferType = false) where T : class;
+
+ T GetHomeItem<T>(bool isLazy = false, bool inferType = false) where T : class;
+ }
+}
+
@@ -0,0 +1,81 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Sitecore.Data.Items;
+
+namespace Glass.Mapper.Sc
+{
+ public class SitecoreContext : SitecoreService, ISitecoreContext
+ {
+ public SitecoreContext()
+ : base(global::Sitecore.Context.Database)
+ {
+
+ }
+ #region ISitecoreContext Members
+
+
+
+
+ public T GetHomeItem<T>(bool isLazy = false, bool inferType = false) where T : class
+ {
+
+ return base.GetItem<T>(global::Sitecore.Context.Site.StartPath, isLazy, inferType);
+ }
+
+ public IEnumerable<T> QueryRelative<T>(string query, bool isLazy, bool inferType) where T : class
+ {
+ Item item = global::Sitecore.Context.Item;
+ var results = item.Axes.SelectItems(query);
+ return base.CreateClasses(isLazy, inferType, typeof(T), () => { return results; }) as IEnumerable<T>;
+
+ }
+
+ public T QuerySingleRelative<T>(string query, bool isLazy, bool inferType) where T : class
+ {
+ Item item = global::Sitecore.Context.Item;
+ var result = item.Axes.SelectSingleItem(query);
+ return base.CreateClass<T>(result,isLazy, inferType);
+ }
+
+
+ public object GetCurrentItem(Type type, bool isLazy = false, bool inferType = false)
+ {
+ return base.CreateClass(type, global::Sitecore.Context.Item, isLazy, inferType);
+ }
+
+ public T GetCurrentItem<T>(bool isLazy = false, bool inferType = false) where T : class
+ {
+ return base.CreateClass<T>(global::Sitecore.Context.Item,isLazy, inferType);
+ }
+
+ public T GetCurrentItem<T, K>(K param1, bool isLazy = false, bool inferType = false) where T : class
+ {
+
+ return base.CreateClass<T, K>(global::Sitecore.Context.Item, param1,isLazy, inferType);
+
+ }
+
+ public T GetCurrentItem<T, K, L>(K param1, L param2, bool isLazy = false, bool inferType = false) where T : class
+ {
+ return base.CreateClass<T, K, L>(global::Sitecore.Context.Item, param1, param2,isLazy, inferType);
+
+ }
+
+ public T GetCurrentItem<T, K, L, M>(K param1, L param2, M param3, bool isLazy = false, bool inferType = false) where T : class
+ {
+ return base.CreateClass<T, K, L, M>(global::Sitecore.Context.Item, param1, param2, param3, isLazy, inferType);
+
+ }
+
+ public T GetCurrentItem<T, K, L, M, N>(K param1, L param2, M param3, N param4, bool isLazy = false, bool inferType = false) where T : class
+ {
+ return base.CreateClass<T, K, L, M, N>(global::Sitecore.Context.Item, param1, param2, param3, param4, isLazy, inferType);
+
+ }
+
+ #endregion
+
+ }
+}
Oops, something went wrong. Retry.

0 comments on commit a52d263

Please sign in to comment.