2014-07-24 11:59:37 +02:00
|
|
|
|
using System;
|
2016-10-07 14:34:55 +02:00
|
|
|
|
using Umbraco.Core.DI;
|
2014-07-24 11:59:37 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core.Models.PublishedContent
|
2014-05-18 21:23:09 +02:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Provides strongly typed published content models services.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal static class PublishedContentExtensionsForModels
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Creates a strongly typed published content model for an internal published content.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="content">The internal published content.</param>
|
|
|
|
|
|
/// <returns>The strongly typed published content model.</returns>
|
|
|
|
|
|
public static IPublishedContent CreateModel(this IPublishedContent content)
|
|
|
|
|
|
{
|
2014-07-24 11:59:37 +02:00
|
|
|
|
if (content == null)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
// get model
|
|
|
|
|
|
// if factory returns nothing, throw
|
2016-08-23 11:06:48 +02:00
|
|
|
|
var model = Current.PublishedContentModelFactory.CreateModel(content);
|
2014-07-24 11:59:37 +02:00
|
|
|
|
if (model == null)
|
|
|
|
|
|
throw new Exception("IPublishedContentFactory returned null.");
|
|
|
|
|
|
|
|
|
|
|
|
return model;
|
2014-05-18 21:23:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|