Continueing implementation of the EntityRepository and Service.

This commit is contained in:
Morten Christensen
2013-03-25 18:54:12 -01:00
parent 40a9da5ee0
commit dfa1e73ddf
6 changed files with 337 additions and 142 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Core.Models
@@ -8,6 +9,8 @@ namespace Umbraco.Core.Models
/// </summary>
public static class UmbracoObjectTypesExtensions
{
private static readonly Dictionary<UmbracoObjectTypes, Guid> UmbracoObjectTypeCache = new Dictionary<UmbracoObjectTypes,Guid>();
/// <summary>
/// Get an UmbracoObjectTypes value from it's name
/// </summary>
@@ -45,10 +48,15 @@ namespace Umbraco.Core.Models
/// <returns>a GUID value of the UmbracoObjectTypes</returns>
public static Guid GetGuid(this UmbracoObjectTypes umbracoObjectType)
{
if (UmbracoObjectTypeCache.ContainsKey(umbracoObjectType))
return UmbracoObjectTypeCache[umbracoObjectType];
var attribute = umbracoObjectType.GetType().FirstAttribute<UmbracoObjectTypeAttribute>();
if (attribute == null)
return Guid.Empty;
UmbracoObjectTypeCache.Add(umbracoObjectType, attribute.ObjectId);
return attribute.ObjectId;
}