mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-24 05:42:10 +08:00
#19118: Fixing shape tracing module expression for Shape items
Work Item: 19118 --HG-- branch : 1.x
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Xml.Linq;
|
||||
using ClaySharp;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
|
||||
namespace Orchard.DesignerTools.Services {
|
||||
|
||||
@@ -86,8 +87,33 @@ namespace Orchard.DesignerTools.Services {
|
||||
DumpShape((IShape) o);
|
||||
|
||||
// a shape can also be IEnumerable
|
||||
if (o is IEnumerable) {
|
||||
DumpEnumerable((IEnumerable) o);
|
||||
if (o is Shape) {
|
||||
var items = o.GetType()
|
||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
.FirstOrDefault(m => m.Name == "Items");
|
||||
|
||||
var classes = o.GetType()
|
||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
.FirstOrDefault(m => m.Name == "Classes");
|
||||
|
||||
var attributes = o.GetType()
|
||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
.FirstOrDefault(m => m.Name == "Attributes");
|
||||
|
||||
if (classes != null) {
|
||||
DumpMember(o, classes);
|
||||
}
|
||||
|
||||
if (attributes != null) {
|
||||
DumpMember(o, attributes);
|
||||
}
|
||||
|
||||
if (items != null) {
|
||||
DumpMember(o, items);
|
||||
}
|
||||
|
||||
|
||||
// DumpEnumerable((IEnumerable) o);
|
||||
}
|
||||
}
|
||||
else if (o is IEnumerable) {
|
||||
@@ -109,7 +135,7 @@ namespace Orchard.DesignerTools.Services {
|
||||
.Where(m => !m.Name.StartsWith("_")) // remove members with a name starting with '_' (usually proxied objects)
|
||||
.ToList();
|
||||
|
||||
if(members.Count() == 0) {
|
||||
if(!members.Any()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -214,8 +240,9 @@ namespace Orchard.DesignerTools.Services {
|
||||
}
|
||||
|
||||
private static string FormatType(object item) {
|
||||
if(item is IShape) {
|
||||
return ((IShape)item).Metadata.Type + " Shape";
|
||||
var shape = item as IShape;
|
||||
if (shape != null) {
|
||||
return shape.Metadata.Type + " Shape";
|
||||
}
|
||||
|
||||
return FormatType(item.GetType());
|
||||
@@ -223,7 +250,7 @@ namespace Orchard.DesignerTools.Services {
|
||||
|
||||
private static string FormatType(Type type) {
|
||||
if (type.IsGenericType) {
|
||||
var genericArguments = String.Join(", ", type.GetGenericArguments().Select(t => FormatType((Type)t)).ToArray());
|
||||
var genericArguments = String.Join(", ", type.GetGenericArguments().Select(FormatType).ToArray());
|
||||
return String.Format("{0}<{1}>", type.Name.Substring(0, type.Name.IndexOf('`')), genericArguments);
|
||||
}
|
||||
|
||||
@@ -244,17 +271,16 @@ namespace Orchard.DesignerTools.Services {
|
||||
}
|
||||
|
||||
private void RestoreCurrentNode() {
|
||||
if (_current.DescendantNodes().Count() == 0) {
|
||||
if (!_current.DescendantNodes().Any()) {
|
||||
_current.Remove();
|
||||
}
|
||||
|
||||
_current = _currents.Pop();
|
||||
}
|
||||
|
||||
private XElement EnterNode(string tag) {
|
||||
private void EnterNode(string tag) {
|
||||
SaveCurrentNode();
|
||||
_current.Add(_current = new XElement(tag));
|
||||
return _current;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user