// Copyright (c) Umbraco. // See LICENSE for more details. using System.ComponentModel; using Umbraco.Cms.Core.Configuration.Models; using Umbraco.Extensions; namespace Umbraco.Cms.Core.Configuration.Models { /// /// Typed configuration options for models builder settings. /// [UmbracoOptions(Constants.Configuration.ConfigModelsBuilder, BindNonPublicProperties = true)] public class ModelsBuilderSettings { private bool _flagOutOfDateModels = true; internal const string StaticModelsMode = "InMemoryAuto"; internal const string StaticModelsDirectory = "~/umbraco/models"; internal const bool StaticAcceptUnsafeModelsDirectory = false; internal const int StaticDebugLevel = 0; /// /// Gets or sets a value for the models mode. /// [DefaultValue(StaticModelsMode)] public ModelsMode ModelsMode { get; set; } = Enum.Parse(StaticModelsMode); /// /// Gets or sets a value for models namespace. /// /// That value could be overriden by other (attribute in user's code...). Return default if no value was supplied. [DefaultValue(Constants.ModelsBuilder.DefaultModelsNamespace)] public string ModelsNamespace { get; set; } = Constants.ModelsBuilder.DefaultModelsNamespace; /// /// Gets or sets a value indicating whether we should flag out-of-date models. /// /// /// Models become out-of-date when data types or content types are updated. When this /// setting is activated the ~/umbraco/models/PureLive/ood.txt file is then created. When models are /// generated through the dashboard, the files is cleared. Default value is false. /// public bool FlagOutOfDateModels { get => _flagOutOfDateModels; set { if (!ModelsMode.IsAuto()) { _flagOutOfDateModels = false; } _flagOutOfDateModels = value; } } /// /// Gets or sets a value for the models directory. /// /// Default is ~/umbraco/models but that can be changed. [DefaultValue(StaticModelsDirectory)] public string ModelsDirectory { get; set; } = StaticModelsDirectory; /// /// Gets or sets a value indicating whether to accept an unsafe value for ModelsDirectory. /// /// /// An unsafe value is an absolute path, or a relative path pointing outside /// of the website root. /// [DefaultValue(StaticAcceptUnsafeModelsDirectory)] public bool AcceptUnsafeModelsDirectory { get; set; } = StaticAcceptUnsafeModelsDirectory; /// /// Gets or sets a value indicating the debug log level. /// /// 0 means minimal (safe on live site), anything else means more and more details (maybe not safe). [DefaultValue(StaticDebugLevel)] public int DebugLevel { get; set; } = StaticDebugLevel; } }