restores the MB enable flag

This commit is contained in:
Shannon
2019-10-29 11:02:18 +11:00
parent cd89308711
commit 2c9939e516
14 changed files with 141 additions and 74 deletions

View File

@@ -22,11 +22,18 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
{
const string prefix = "Umbraco.ModelsBuilder.";
// giant kill switch, default: false
// must be explicitely set to true for anything else to happen
Enable = ConfigurationManager.AppSettings[prefix + "Enable"] == "true";
// ensure defaults are initialized for tests
ModelsNamespace = DefaultModelsNamespace;
ModelsDirectory = IOHelper.MapPath(DefaultModelsDirectory);
DebugLevel = 0;
// stop here, everything is false
if (!Enable) return;
// mode
var modelsMode = ConfigurationManager.AppSettings[prefix + "ModelsMode"];
if (!string.IsNullOrWhiteSpace(modelsMode))
@@ -94,6 +101,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
/// Initializes a new instance of the <see cref="ModelsBuilderConfig"/> class.
/// </summary>
public ModelsBuilderConfig(
bool enable = false,
ModelsMode modelsMode = ModelsMode.Nothing,
string modelsNamespace = null,
bool enableFactory = true,
@@ -102,6 +110,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
bool acceptUnsafeModelsDirectory = false,
int debugLevel = 0)
{
Enable = enable;
ModelsMode = modelsMode;
ModelsNamespace = string.IsNullOrWhiteSpace(modelsNamespace) ? DefaultModelsNamespace : modelsNamespace;
@@ -143,6 +152,15 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
throw new ConfigurationErrorsException($"Invalid models directory \"{config}\".");
}
/// <summary>
/// Gets a value indicating whether the whole models experience is enabled.
/// </summary>
/// <remarks>
/// <para>If this is false then absolutely nothing happens.</para>
/// <para>Default value is <c>false</c> which means that unless we have this setting, nothing happens.</para>
/// </remarks>
public bool Enable { get; }
/// <summary>
/// Gets the models mode.
/// </summary>