mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
More adjustments to namespace... Some planning...
--HG-- branch : mvc3p1
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Text;
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Orchard.DisplayManagement;
|
using Orchard.DisplayManagement;
|
||||||
|
using Orchard.DisplayManagement.Implementation;
|
||||||
using Orchard.DisplayManagement.Shapes;
|
using Orchard.DisplayManagement.Shapes;
|
||||||
|
|
||||||
namespace Orchard.Tests.DisplayManagement {
|
namespace Orchard.Tests.DisplayManagement {
|
||||||
|
@@ -8,7 +8,6 @@ using Autofac;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Orchard.DisplayManagement;
|
using Orchard.DisplayManagement;
|
||||||
using Orchard.DisplayManagement.Implementation;
|
using Orchard.DisplayManagement.Implementation;
|
||||||
using Orchard.DisplayManagement.Secondary;
|
|
||||||
using Orchard.DisplayManagement.Shapes;
|
using Orchard.DisplayManagement.Shapes;
|
||||||
|
|
||||||
namespace Orchard.Tests.DisplayManagement {
|
namespace Orchard.Tests.DisplayManagement {
|
||||||
|
@@ -20,10 +20,10 @@ namespace Orchard.DevTools.Controllers {
|
|||||||
public HomeController(INotifier notifier, IShapeHelperFactory shapeHelperFactory) {
|
public HomeController(INotifier notifier, IShapeHelperFactory shapeHelperFactory) {
|
||||||
_notifier = notifier;
|
_notifier = notifier;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
New = shapeHelperFactory.CreateHelper();
|
Shape = shapeHelperFactory.CreateHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic New { get; set; }
|
dynamic Shape { get; set; }
|
||||||
|
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
@@ -58,18 +58,18 @@ namespace Orchard.DevTools.Controllers {
|
|||||||
|
|
||||||
public ActionResult UsingShapes() {
|
public ActionResult UsingShapes() {
|
||||||
|
|
||||||
ViewModel.Page = New.Page()
|
ViewModel.Page = Shape.Page()
|
||||||
.Main(New.Zone(typeof (Array), Name: "Main"))
|
.Main(Shape.Zone(typeof (Array), Name: "Main"))
|
||||||
.Messages(New.Zone(typeof (Array), Name: "Messages"))
|
.Messages(Shape.Zone(typeof (Array), Name: "Messages"))
|
||||||
.Sidebar(New.Zone(typeof (Array), Name: "Sidebar"));
|
.Sidebar(Shape.Zone(typeof (Array), Name: "Sidebar"));
|
||||||
|
|
||||||
ViewModel.Page.Add("Messages:5", New.Message(Content: T("This is a test"), Severity: "Really bad!!!"));
|
//ViewModel.Page.Add("Messages:5", New.Message(Content: T("This is a test"), Severity: "Really bad!!!"));
|
||||||
|
|
||||||
ViewModel.Page.Messages.Add(
|
ViewModel.Page.Messages.Add(
|
||||||
New.Message(Content: T("This is a test"), Severity: "Really bad!!!"));
|
Shape.Message(Content: T("This is a test"), Severity: "Really bad!!!"));
|
||||||
|
|
||||||
var model = New.Message(
|
var model = Shape.Message(
|
||||||
Content: New.Explosion(Height: 100, Width: 200),
|
Content: Shape.Explosion(Height: 100, Width: 200),
|
||||||
Severity: "Meh");
|
Severity: "Meh");
|
||||||
|
|
||||||
ViewModel.Page.Messages.Add(new HtmlString("<hr/>abuse<hr/>"));
|
ViewModel.Page.Messages.Add(new HtmlString("<hr/>abuse<hr/>"));
|
||||||
|
@@ -24,15 +24,16 @@ namespace Orchard.DevTools {
|
|||||||
tag.GenerateId("zone-" + Shape.Name);
|
tag.GenerateId("zone-" + Shape.Name);
|
||||||
tag.AddCssClass("zone-" + Shape.Name);
|
tag.AddCssClass("zone-" + Shape.Name);
|
||||||
tag.AddCssClass("zone");
|
tag.AddCssClass("zone");
|
||||||
tag.InnerHtml = Smash(DisplayAll(Display, Shape)).ToString();
|
tag.InnerHtml = Combine(DisplayAll(Display, Shape).ToArray()).ToString();
|
||||||
return new HtmlString(tag.ToString());
|
return new HtmlString(tag.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHtmlString Message(dynamic Display, object Content, string Severity) {
|
public IHtmlString Message(dynamic Display, object Content, string Severity) {
|
||||||
return Display(new HtmlString("<p class=\"message\">"), Severity ?? "Neutral", ": ", Content, new HtmlString("</p>"));
|
return Display(new HtmlString("<p class=\"message\">"), Severity ?? "Neutral", ": ", Content, new HtmlString("</p>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IHtmlString Smash(IEnumerable<IHtmlString> contents) {
|
|
||||||
|
static IHtmlString Combine(IEnumerable<IHtmlString> contents) {
|
||||||
return new HtmlString(contents.Aggregate("", (a, b) => a + b));
|
return new HtmlString(contents.Aggregate("", (a, b) => a + b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,7 +13,6 @@ using Orchard.Data.Providers;
|
|||||||
using Orchard.Data.Migration;
|
using Orchard.Data.Migration;
|
||||||
using Orchard.DisplayManagement;
|
using Orchard.DisplayManagement;
|
||||||
using Orchard.DisplayManagement.Implementation;
|
using Orchard.DisplayManagement.Implementation;
|
||||||
using Orchard.DisplayManagement.Secondary;
|
|
||||||
using Orchard.DisplayManagement.Shapes;
|
using Orchard.DisplayManagement.Shapes;
|
||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Web.Mvc;
|
||||||
using System.Web.Mvc;
|
|
||||||
|
|
||||||
namespace Orchard.DisplayManagement {
|
namespace Orchard.DisplayManagement {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
using System.Runtime.CompilerServices;
|
namespace Orchard.DisplayManagement {
|
||||||
using Orchard.DisplayManagement.Shapes;
|
|
||||||
|
|
||||||
namespace Orchard.DisplayManagement {
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface present on dynamic shapes.
|
/// Interface present on dynamic shapes.
|
||||||
/// May be used to access attributes in a strongly typed fashion.
|
/// May be used to access attributes in a strongly typed fashion.
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using ClaySharp;
|
using ClaySharp;
|
||||||
using Orchard.DisplayManagement.Shapes;
|
|
||||||
|
|
||||||
namespace Orchard.DisplayManagement {
|
namespace Orchard.DisplayManagement {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@@ -3,21 +3,20 @@ using System.Dynamic;
|
|||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
|
||||||
using Microsoft.CSharp.RuntimeBinder;
|
using Microsoft.CSharp.RuntimeBinder;
|
||||||
using Orchard.DisplayManagement.Implementation;
|
|
||||||
using Orchard.DisplayManagement.Shapes;
|
using Orchard.DisplayManagement.Shapes;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
|
|
||||||
namespace Orchard.DisplayManagement.Secondary {
|
namespace Orchard.DisplayManagement.Implementation {
|
||||||
public class DefaultDisplayManager : IDisplayManager {
|
public class DefaultDisplayManager : IDisplayManager {
|
||||||
private readonly IShapeTableFactory _shapeTableFactory;
|
private readonly IShapeTableFactory _shapeTableFactory;
|
||||||
|
|
||||||
private static CallSite<Func<CallSite, object, IShape>> _convertAsShapeCallsite = CallSite<Func<CallSite, object, IShape>>.Create(
|
// this need to be Shape instead of IShape - cast to interface throws error on clr types like HtmlString
|
||||||
|
private static readonly CallSite<Func<CallSite, object, Shape>> _convertAsShapeCallsite = CallSite<Func<CallSite, object, Shape>>.Create(
|
||||||
new ForgivingConvertBinder(
|
new ForgivingConvertBinder(
|
||||||
(ConvertBinder)Binder.Convert(
|
(ConvertBinder)Binder.Convert(
|
||||||
CSharpBinderFlags.ConvertExplicit | CSharpBinderFlags.CheckedContext,
|
CSharpBinderFlags.ConvertExplicit,
|
||||||
typeof(IShape),
|
typeof(Shape),
|
||||||
null/*typeof(DefaultDisplayManager)*/)));
|
null/*typeof(DefaultDisplayManager)*/)));
|
||||||
|
|
||||||
public DefaultDisplayManager(IShapeTableFactory shapeTableFactory) {
|
public DefaultDisplayManager(IShapeTableFactory shapeTableFactory) {
|
||||||
@@ -41,10 +40,13 @@ namespace Orchard.DisplayManagement.Secondary {
|
|||||||
return CoerceHtmlString(context.Value);
|
return CoerceHtmlString(context.Value);
|
||||||
|
|
||||||
var shapeTable = _shapeTableFactory.CreateShapeTable();
|
var shapeTable = _shapeTableFactory.CreateShapeTable();
|
||||||
|
//preproc loop / event (alter shape, swapping type)
|
||||||
|
|
||||||
ShapeTable.Entry entry;
|
ShapeTable.Entry entry;
|
||||||
if (shapeTable.Entries.TryGetValue(shapeAttributes.Type, out entry)) {
|
if (shapeTable.Entries.TryGetValue(shapeAttributes.Type, out entry)) {
|
||||||
return Process(entry, shape, context);
|
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", shapeAttributes.Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ClaySharp;
|
using ClaySharp;
|
||||||
|
using Orchard.DisplayManagement.Shapes;
|
||||||
|
|
||||||
namespace Orchard.DisplayManagement.Shapes {
|
namespace Orchard.DisplayManagement.Implementation {
|
||||||
public class DefaultShapeFactory : IShapeFactory {
|
public class DefaultShapeFactory : IShapeFactory {
|
||||||
public IShape Create(string shapeType, INamedEnumerable<object> parameters) {
|
public IShape Create(string shapeType, INamedEnumerable<object> parameters) {
|
||||||
|
|
||||||
|
@@ -1,12 +1,6 @@
|
|||||||
using System;
|
using System.Web.Mvc;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Web.Mvc;
|
|
||||||
using Orchard.DisplayManagement.Shapes;
|
|
||||||
|
|
||||||
namespace Orchard.DisplayManagement {
|
namespace Orchard.DisplayManagement.Implementation {
|
||||||
public class DisplayContext {
|
public class DisplayContext {
|
||||||
public DisplayHelper Display { get; set; }
|
public DisplayHelper Display { get; set; }
|
||||||
public ViewContext ViewContext { get; set; }
|
public ViewContext ViewContext { get; set; }
|
||||||
|
@@ -1,13 +1,10 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using ClaySharp;
|
using ClaySharp;
|
||||||
using Orchard.DisplayManagement.Implementation;
|
|
||||||
using Orchard.DisplayManagement.Shapes;
|
|
||||||
|
|
||||||
namespace Orchard.DisplayManagement {
|
namespace Orchard.DisplayManagement.Implementation {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Refactor: I this doesn't really need to exist, does it?
|
/// Refactor: I this doesn't really need to exist, does it?
|
||||||
|
@@ -1,10 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using ClaySharp;
|
using ClaySharp;
|
||||||
using Orchard.DisplayManagement.Implementation;
|
|
||||||
using Orchard.DisplayManagement.Shapes;
|
|
||||||
|
|
||||||
namespace Orchard.DisplayManagement {
|
namespace Orchard.DisplayManagement.Implementation {
|
||||||
public class DisplayHelperFactory : IDisplayHelperFactory {
|
public class DisplayHelperFactory : IDisplayHelperFactory {
|
||||||
static private readonly DisplayHelperBehavior[] _behaviors = new[] { new DisplayHelperBehavior() };
|
static private readonly DisplayHelperBehavior[] _behaviors = new[] { new DisplayHelperBehavior() };
|
||||||
private readonly IDisplayManager _displayManager;
|
private readonly IDisplayManager _displayManager;
|
||||||
|
@@ -7,6 +7,7 @@ using System.Reflection;
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using Microsoft.CSharp.RuntimeBinder;
|
using Microsoft.CSharp.RuntimeBinder;
|
||||||
|
using Orchard.DisplayManagement.Implementation;
|
||||||
using Binder = Microsoft.CSharp.RuntimeBinder.Binder;
|
using Binder = Microsoft.CSharp.RuntimeBinder.Binder;
|
||||||
|
|
||||||
namespace Orchard.DisplayManagement {
|
namespace Orchard.DisplayManagement {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
using Orchard.DisplayManagement.Implementation;
|
||||||
|
|
||||||
namespace Orchard.DisplayManagement {
|
namespace Orchard.DisplayManagement {
|
||||||
public class ShapeTable {
|
public class ShapeTable {
|
||||||
|
Reference in New Issue
Block a user