Files
Umbraco-CMS/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs

84 lines
3.3 KiB
C#
Raw Normal View History

// Copyright (c) Umbraco.
// See LICENSE for more details.
using System.ComponentModel;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Extensions;
2020-03-16 14:02:08 +01:00
namespace Umbraco.Cms.Core.Configuration.Models
2020-03-16 14:02:08 +01:00
{
/// <summary>
/// Typed configuration options for models builder settings.
2020-03-16 14:02:08 +01:00
/// </summary>
[UmbracoOptions(Constants.Configuration.ConfigModelsBuilder, BindNonPublicProperties = true)]
public class ModelsBuilderSettings
2020-03-16 14:02:08 +01:00
{
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;
2020-03-18 11:29:29 +01:00
2020-03-16 14:02:08 +01:00
/// <summary>
/// Gets or sets a value for the models mode.
2020-03-16 14:02:08 +01:00
/// </summary>
[DefaultValue(StaticModelsMode)]
public ModelsMode ModelsMode { get; set; } = Enum<ModelsMode>.Parse(StaticModelsMode);
2020-03-16 14:02:08 +01:00
/// <summary>
/// Gets or sets a value for models namespace.
2020-03-16 14:02:08 +01:00
/// </summary>
/// <remarks>That value could be overriden by other (attribute in user's code...). Return default if no value was supplied.</remarks>
[DefaultValue(Constants.ModelsBuilder.DefaultModelsNamespace)]
public string ModelsNamespace { get; set; } = Constants.ModelsBuilder.DefaultModelsNamespace;
2020-03-16 14:02:08 +01:00
/// <summary>
/// Gets or sets a value indicating whether we should flag out-of-date models.
2020-03-16 14:02:08 +01:00
/// </summary>
2020-03-18 11:29:29 +01:00
/// <remarks>
/// 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 <c>false</c>.
2020-03-18 11:29:29 +01:00
/// </remarks>
public bool FlagOutOfDateModels
{
get => _flagOutOfDateModels;
set
{
if (!ModelsMode.IsAuto())
{
_flagOutOfDateModels = false;
}
_flagOutOfDateModels = value;
}
}
2020-03-16 14:02:08 +01:00
/// <summary>
/// Gets or sets a value for the models directory.
2020-03-16 14:02:08 +01:00
/// </summary>
/// <remarks>Default is ~/umbraco/models but that can be changed.</remarks>
[DefaultValue(StaticModelsDirectory)]
public string ModelsDirectory { get; set; } = StaticModelsDirectory;
2020-03-16 14:02:08 +01:00
2020-03-16 14:02:08 +01:00
/// <summary>
/// Gets or sets a value indicating whether to accept an unsafe value for ModelsDirectory.
2020-03-16 14:02:08 +01:00
/// </summary>
2020-03-18 11:29:29 +01:00
/// <remarks>
/// An unsafe value is an absolute path, or a relative path pointing outside
/// of the website root.
2020-03-18 11:29:29 +01:00
/// </remarks>
[DefaultValue(StaticAcceptUnsafeModelsDirectory)]
public bool AcceptUnsafeModelsDirectory { get; set; } = StaticAcceptUnsafeModelsDirectory;
2020-03-16 14:02:08 +01:00
/// <summary>
/// Gets or sets a value indicating the debug log level.
2020-03-16 14:02:08 +01:00
/// </summary>
/// <remarks>0 means minimal (safe on live site), anything else means more and more details (maybe not safe).</remarks>
[DefaultValue(StaticDebugLevel)]
public int DebugLevel { get; set; } = StaticDebugLevel;
2020-03-16 14:02:08 +01:00
}
}