Fixing shape display when casting to Shape explicitly

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2013-02-04 12:58:45 -08:00
parent a6209ff7f4
commit c9404b80d6
2 changed files with 9 additions and 1 deletions

View File

@@ -79,12 +79,14 @@ namespace Orchard.Tests.DisplayManagement {
dynamic shapeHelperFactory = _container.Resolve<IShapeFactory>();
var result1 = displayHelperFactory.Something();
var result2 = ((DisplayHelper)displayHelperFactory).ShapeExecute((Shape)shapeHelperFactory.Pager());
var result2 = ((DisplayHelper)displayHelperFactory).ShapeExecute(shapeHelperFactory.Pager());
var result3 = ((DisplayHelper)displayHelperFactory).ShapeExecute((Shape)shapeHelperFactory.Pager());
displayHelperFactory(shapeHelperFactory.Pager());
Assert.That(result1.ToString(), Is.EqualTo("<br/>"));
Assert.That(result2.ToString(), Is.EqualTo("<div>hello</div>"));
Assert.That(result3.ToString(), Is.EqualTo("<div>hello</div>"));
}
}
}

View File

@@ -3,6 +3,7 @@ using System.Dynamic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Orchard.DisplayManagement.Shapes;
namespace Orchard.DisplayManagement.Implementation {
@@ -71,6 +72,11 @@ namespace Orchard.DisplayManagement.Implementation {
return ShapeExecute(shape);
}
public object ShapeExecute(Shape shape) {
// disambiguates the call to ShapeExecute(object) as Shape also implements IEnumerable
return ShapeExecute((object) shape);
}
public object ShapeExecute(object shape) {
if (shape == null) {
return new HtmlString(string.Empty);