Changing (Shape) Attributes to ShapeMetadata (could instead to with just Metadata)

--HG--
branch : mvc3p1
This commit is contained in:
Nathan Heskew
2010-08-27 13:48:56 -07:00
parent 12a6b63840
commit ff43a359bc
9 changed files with 15 additions and 14 deletions

View File

@@ -56,7 +56,7 @@ namespace Orchard.Tests.DisplayManagement {
var displayHelperFactory = new DisplayHelperFactory(displayManager.Object, shapeFactory.Object);
var display = (dynamic)displayHelperFactory.CreateHelper(viewContext, null);
var outline = new Shape { Attributes = new ShapeAttributes { Type = "Outline" } };
var outline = new Shape { ShapeMetadata = new ShapeMetadata { Type = "Outline" } };
display(outline);
//displayManager.Verify(dm => dm.Execute(outline, viewContext, null));

View File

@@ -25,8 +25,8 @@ namespace Orchard.Tests.DisplayManagement {
public void ShapeHasAttributesType() {
var factory = _container.Resolve<IShapeFactory>();
dynamic foo = factory.Create("Foo", ArgsUtility.Empty());
ShapeAttributes attributes = foo.Attributes;
Assert.That(attributes.Type, Is.EqualTo("Foo"));
ShapeMetadata metadata = foo.Attributes;
Assert.That(metadata.Type, Is.EqualTo("Foo"));
}
[Test]

View File

@@ -5,6 +5,6 @@
/// Note: Anything on this interface is a reserved word for the purpose of shape properties
/// </summary>
public interface IShape {
IShapeAttributes Attributes { get; set; }
IShapeMetadata ShapeMetadata { get; set; }
}
}

View File

@@ -1,5 +1,5 @@
namespace Orchard.DisplayManagement {
public interface IShapeAttributes {
public interface IShapeMetadata {
string Type { get; set; }
string Position { get; set; }
}

View File

@@ -34,20 +34,20 @@ namespace Orchard.DisplayManagement.Implementation {
if (shape == null)
return CoerceHtmlString(context.Value);
var shapeAttributes = shape.Attributes;
var shapeMetadata = shape.ShapeMetadata;
// can't really cope with a shape that has no type information
if (shapeAttributes == null || string.IsNullOrEmpty(shapeAttributes.Type))
if (shapeMetadata == null || string.IsNullOrEmpty(shapeMetadata.Type))
return CoerceHtmlString(context.Value);
var shapeTable = _shapeTableFactory.CreateShapeTable();
//preproc loop / event (alter shape, swapping type)
ShapeTable.Entry entry;
if (shapeTable.Entries.TryGetValue(shapeAttributes.Type, out entry)) {
if (shapeTable.Entries.TryGetValue(shapeMetadata.Type, out entry)) {
return Process(entry, shape, context);
}
//postproc / content html alteration/wrapping/etc
throw new OrchardException(T("Shape type {0} not found", shapeAttributes.Type));
throw new OrchardException(T("Shape type {0} not found", shapeMetadata.Type));
}
private IHtmlString CoerceHtmlString(object value) {

View File

@@ -41,7 +41,7 @@ namespace Orchard.DisplayManagement.Implementation {
// consideration - types without default constructors could consume positional arguments?
var shape = ClayActivator.CreateInstance(baseType, behaviors);
shape.Attributes = new ShapeAttributes { Type = shapeType };
shape.ShapeMetadata = new ShapeMetadata { Type = shapeType };
// only one non-Type, non-named argument is allowed
var initializer = positional.SingleOrDefault();

View File

@@ -1,5 +1,5 @@
namespace Orchard.DisplayManagement.Shapes {
public class Shape : IShape {
public virtual IShapeAttributes Attributes { get; set; }
public virtual IShapeMetadata ShapeMetadata { get; set; }
}
}

View File

@@ -1,5 +1,5 @@
namespace Orchard.DisplayManagement.Shapes {
public class ShapeAttributes : IShapeAttributes {
public class ShapeMetadata : IShapeMetadata {
public string Type { get; set; }
public string Position { get; set; }
}

View File

@@ -382,9 +382,9 @@
<Compile Include="DisplayManagement\IShapeHelperFactory.cs" />
<Compile Include="DisplayManagement\IDisplayHelperFactory.cs" />
<Compile Include="DisplayManagement\IShape.cs" />
<Compile Include="DisplayManagement\IShapeAttributes.cs" />
<Compile Include="DisplayManagement\IShapeMetadata.cs" />
<Compile Include="DisplayManagement\Shapes\Shape.cs" />
<Compile Include="DisplayManagement\Shapes\ShapeAttributes.cs" />
<Compile Include="DisplayManagement\Shapes\ShapeMetadata.cs" />
<Compile Include="DisplayManagement\Speculation\DefaultShapeTableFactory.cs" />
<Compile Include="DisplayManagement\Implementation\DisplayContext.cs" />
<Compile Include="DisplayManagement\Implementation\DisplayHelper.cs" />
@@ -400,6 +400,7 @@
<Compile Include="Environment\IHostLocalRestart.cs" />
<Compile Include="Environment\IShellContainerRegistrations.cs" />
<Compile Include="FileSystems\Dependencies\DynamicModuleVirtualPathProvider.cs" />
<Compile Include="Mvc\Html\Shapes.cs" />
<Compile Include="Mvc\ViewEngines\Razor\RazorCompilationEventsShim.cs" />
<Compile Include="Mvc\ViewEngines\Razor\RazorViewEngineProvider.cs" />
<Compile Include="Mvc\ViewEngines\Razor\WebViewPage.cs" />