Fixes ServiceContext to ensure the repo's are lazy instantiated because their ctor's rely on the

RepositoryResolver.Current being initialized which normally doesn't occur until after the ServiceContext
is constructed. Adds instance level caching for the GetRecursiveValue method in case this is called more than
one time for a property in one view. Reverts PetaPocoUnitOfWork to allow more than one call to Commit().. this
isn't 'best practices' per se but it is more for performance reasons because otherwise we'd have to create a new
repo object + uow for any bulk saving operations... The end result is the same, bulk operations in the Services
cannot be processed in one transaction. Fixing up the ContentServiceTests by ensuring that the shared and always open sqlce
connection with the legacy SqlCeContextGuardian is closed on TearDown.
This commit is contained in:
Shannon Deminick
2012-12-15 10:33:29 +05:00
parent ad7aa66b0b
commit b73efd16dc
6 changed files with 98 additions and 71 deletions

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Data;
using System.Net.Mime;
using System.Web;
using Umbraco.Core.Dynamics;
using Umbraco.Core.Models;
using umbraco.interfaces;
@@ -83,6 +84,13 @@ namespace Umbraco.Core
/// <returns></returns>
public static string GetRecursiveValue(this IPublishedContent publishedContent, string fieldname)
{
//check for the cached value in the objects properties first
var cachedVal = publishedContent["__recursive__" + fieldname];
if (cachedVal != null)
{
return cachedVal.ToString();
}
var contentValue = "";
var currentContent = publishedContent;
@@ -102,6 +110,10 @@ namespace Umbraco.Core
contentValue = val.ToString(); //we've found a recursive val
}
}
//cache this lookup in a new custom (hidden) property
publishedContent.Properties.Add(new PropertyResult("__recursive__" + fieldname, contentValue, Guid.Empty, PropertyResultType.CustomProperty));
return contentValue;
}