Skip to content

Instantly share code, notes, and snippets.

@mikeedwards83
Created October 7, 2012 14:36
Show Gist options
  • Select an option

  • Save mikeedwards83/3848558 to your computer and use it in GitHub Desktop.

Select an option

Save mikeedwards83/3848558 to your computer and use it in GitHub Desktop.
Fix for SitecoreRenderingsHandler
public class SitecoreRenderingsHandler : AbstractSitecoreDataHandler
{
public override bool WillHandle(SitecoreProperty property, IEnumerable<AbstractSitecoreDataHandler> datas, Dictionary<Type, SitecoreClassConfig> classes)
{
//it was this:
//return property.Attribute is SitecoreRenderingsAttribute && property.Property == typeof(IEnumerable<RenderingReference>);
//should be this
return property.Attribute is SitecoreRenderingsAttribute && property.Property.PropertyType == typeof(IEnumerable<RenderingReference>);
}
public override object GetValue(Item item, ISitecoreService service)
{
//you may want to lazy load this
var device = item.Database.GetItem("/sitecore/layout/Devices/" + Device.ToString());
return item.Visualization.GetRenderings(new DeviceItem(device), false);
}
public override void SetValue(Item item, object value, ISitecoreService service)
{
throw new NotImplementedException();
}
public override bool CanSetValue
{
get { return false; }
}
public override void ConfigureDataHandler(SitecoreProperty scProperty)
{
var attr = scProperty.Attribute as SitecoreRenderingsAttribute;
this.Device = attr.Device;
base.ConfigureDataHandler(scProperty);
}
public Device Device { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment