using System.Runtime.Serialization; using Umbraco.Cms.Core.Strings; namespace Umbraco.Cms.Core.Models; /// /// Represents a Template file that can have its content on disk. /// [Serializable] [DataContract(IsReference = true)] public class TemplateOnDisk : Template { /// /// Initializes a new instance of the class. /// /// The name of the template. /// The alias of the template. /// The short string helper public TemplateOnDisk(IShortStringHelper shortStringHelper, string name, string alias) : base(shortStringHelper, name, alias) => IsOnDisk = true; /// /// Gets or sets a value indicating whether the content is on disk already. /// public bool IsOnDisk { get; set; } /// /// Gets or sets the content. /// /// /// /// Getting the content while the template is "on disk" throws, /// the template must be saved before its content can be retrieved. /// /// /// Setting the content means it is not "on disk" anymore, and the /// template becomes (and behaves like) a normal template. /// /// public override string? Content { get => IsOnDisk ? string.Empty : base.Content; set { base.Content = value; IsOnDisk = false; } } }