Changing the ShapeAlterationBuilder to collapse shapes together by base name

ShapeType and BindingName are treated as two strings
Shorter string broken at first delimiter is used as registered ShapeType name
All alterations of the same ShapeType are accumulated into the same ShapeDescriptor

--HG--
branch : theming
This commit is contained in:
Louis DeJardin
2010-09-14 09:59:33 -07:00
parent bab30e826d
commit 789d10cf5e

View File

@@ -7,13 +7,22 @@ using Orchard.Environment.Extensions.Models;
namespace Orchard.DisplayManagement.Descriptors {
public class ShapeAlterationBuilder {
protected Feature _feature;
protected string _shapeType;
protected readonly IList<Action<ShapeDescriptor>> _configurations = new List<Action<ShapeDescriptor>>();
Feature _feature;
readonly string _shapeType;
readonly string _bindingName;
readonly IList<Action<ShapeDescriptor>> _configurations = new List<Action<ShapeDescriptor>>();
public ShapeAlterationBuilder(Feature feature, string shapeType) {
_feature = feature;
_shapeType = shapeType;
_bindingName = shapeType;
var delimiterIndex = shapeType.IndexOf("__");
if (delimiterIndex < 0) {
_shapeType = shapeType;
}
else {
_shapeType = shapeType.Substring(0, delimiterIndex);
}
}
public ShapeAlterationBuilder From(Feature feature) {
@@ -33,7 +42,7 @@ namespace Orchard.DisplayManagement.Descriptors {
Func<DisplayContext, IHtmlString> target = null;
var binding = new ShapeBinding {
BindingName = _shapeType,
BindingName = _bindingName,
BindingSource = bindingSource,
Binding = displayContext => {