Refactored the traversal, ishelper, etc... methods to be extension methods on IPublishedContent so now all of these methods are available on the Typed object not just the dynamic object which makes a whole lot more sense... and you can have intellisense.

Updated DynamicPublishedContent's methods to just proxy calls to the new extension methods so that all of the logic is contained in one place.
Added new GetRootDocuments to the IPublishedContentStore since we need this in order to get the root list of documents for many of these methods.
Fixed an issue with the DynamicNode to IPublishedContent converter.
Fixed many of the failing unit tests.
This commit is contained in:
Shannon Deminick
2012-10-04 01:31:08 +05:00
parent 831d1966dc
commit c0102f1c71
40 changed files with 2391 additions and 2120 deletions

View File

@@ -30,6 +30,12 @@ namespace umbraco.MacroEngines
{
public class DynamicNode : DynamicObject
{
/// <summary>
/// This callback is used only so we can set it dynamically for use in unit tests
/// </summary>
internal static Func<string, string, Guid> GetDataTypeCallback = (docTypeAlias, propertyAlias) =>
ContentType.GetDataType(docTypeAlias, propertyAlias);
#region consts
// these are private readonlys as const can't be Guids
private readonly Guid DATATYPE_YESNO_GUID = new Guid("38b352c1-e9f8-4fd8-9324-9a2eab06d97a");
@@ -503,6 +509,11 @@ namespace umbraco.MacroEngines
}
}
private static Guid GetDataType(string docTypeAlias, string propertyAlias)
{
return GetDataTypeCallback(docTypeAlias, propertyAlias);
}
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
@@ -542,9 +553,8 @@ namespace umbraco.MacroEngines
}
//contextAlias is the node which the property data was returned from
//Guid dataType = ContentType.GetDataType(data.ContextAlias, data.Alias);
//SD: replaced with our temporary resolver so that we can unit test this properly, this is what DynamicPublishedContent uses until we create our new data access layer.
var dataType = DynamicPublishedContentDataSourceResolver.Current.DataSource.GetDataType(data.ContextAlias, data.Alias);
//Guid dataType = ContentType.GetDataType(data.ContextAlias, data.Alias);
var dataType = GetDataType(data.ContextAlias, data.Alias);
var staticMapping = UmbracoSettings.RazorDataTypeModelStaticMapping.FirstOrDefault(mapping =>
{

View File

@@ -2,8 +2,10 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Dynamics;
using Umbraco.Core.Models;
using Umbraco.Web;
using umbraco.NodeFactory;
using umbraco.interfaces;
@@ -12,7 +14,7 @@ namespace umbraco.MacroEngines.Library
/// <summary>
/// Extension methods for converting DynamicPublishedContent to INode
/// </summary>
internal static class DynamicPublishedContentExtensions
internal static class PublishedContentExtensions
{
internal static IProperty ConvertToNodeProperty(this IDocumentProperty prop)
@@ -20,7 +22,7 @@ namespace umbraco.MacroEngines.Library
return new PropertyResult(prop.Alias, prop.Value.ToString(), prop.Version);
}
internal static INode ConvertToNode(this DynamicPublishedContent doc)
internal static INode ConvertToNode(this IPublishedContent doc)
{
var node = new ConvertedNode(doc);
return node;
@@ -31,9 +33,9 @@ namespace umbraco.MacroEngines.Library
/// </summary>
private class ConvertedNode : INode
{
private readonly DynamicPublishedContent _doc;
private readonly IPublishedContent _doc;
public ConvertedNode(DynamicPublishedContent doc)
public ConvertedNode(IPublishedContent doc)
{
_doc = doc;
template = doc.TemplateId;
@@ -109,12 +111,12 @@ namespace umbraco.MacroEngines.Library
public DataTable ChildrenAsTable()
{
throw new NotImplementedException();
return _doc.ChildrenAsTable();
}
public DataTable ChildrenAsTable(string nodeTypeAliasFilter)
{
throw new NotImplementedException();
return _doc.ChildrenAsTable(nodeTypeAliasFilter);
}
}
}

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Web.Mvc;
using Umbraco.Core.Dynamics;
using Umbraco.Core.Models;
using Umbraco.Web;
using umbraco.interfaces;
using System.Xml.Linq;