using System; using System.Globalization; using Umbraco.Core.Models; using Umbraco.Web.Mvc; namespace Umbraco.Web.Models { /// /// Represents the model for the current rendering page in Umbraco /// public class RenderModel : IRenderModel { /// /// Constructor specifying both the IPublishedContent and the CultureInfo /// /// /// public RenderModel(IPublishedContent content, CultureInfo culture) { if (content == null) throw new ArgumentNullException("content"); if (culture == null) throw new ArgumentNullException("culture"); Content = content; CurrentCulture = culture; } /// /// Constructor to set the IPublishedContent and the CurrentCulture is set by the UmbracoContext /// /// public RenderModel(IPublishedContent content) { if (content == null) throw new ArgumentNullException("content"); if (UmbracoContext.Current == null) { throw new InvalidOperationException("Cannot construct a RenderModel without specifying a CultureInfo when no UmbracoContext has been initialized"); } Content = content; CurrentCulture = UmbracoContext.Current.PublishedContentRequest.Culture; } /// /// Returns the current IPublishedContent object /// public IPublishedContent Content { get; private set; } /// /// Returns the current Culture assigned to the page being rendered /// public CultureInfo CurrentCulture { get; private set; } } }