Merge pull request #7751 from cyberdot/temp-7667
NetCore: Abstract ConfigurationManager references
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
{
|
||||
public class ActiveDirectorySettings : IActiveDirectorySettings
|
||||
{
|
||||
public ActiveDirectorySettings()
|
||||
{
|
||||
ActiveDirectoryDomain = ConfigurationManager.AppSettings["ActiveDirectoryDomain"];
|
||||
}
|
||||
|
||||
public string ActiveDirectoryDomain { get; }
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,12 @@ namespace Umbraco.Core.Configuration
|
||||
|
||||
public ICoreDebug CoreDebug { get; } = new CoreDebug();
|
||||
public IMachineKeyConfig MachineKeyConfig { get; } = new MachineKeyConfig();
|
||||
public IIndexCreatorSettings IndexCreatorSettings { get; } = new IndexCreatorSettings();
|
||||
public INuCacheSettings NuCacheSettings { get; } = new NuCacheSettings();
|
||||
public ITypeFinderSettings TypeFinderSettings { get; } = new TypeFinderSettings();
|
||||
public IRuntimeSettings RuntimeSettings { get; } = new RuntimeSettings();
|
||||
public IActiveDirectorySettings ActiveDirectorySettings { get; } = new ActiveDirectorySettings();
|
||||
public IExceptionFilterSettings ExceptionFilterSettings { get; } = new ExceptionFilterSettings();
|
||||
|
||||
public IUmbracoSettingsSection UmbracoSettings { get; }
|
||||
|
||||
@@ -31,6 +37,16 @@ namespace Umbraco.Core.Configuration
|
||||
configs.Add(() => CoreDebug);
|
||||
configs.Add(() => MachineKeyConfig);
|
||||
configs.Add<IConnectionStrings>(() => new ConnectionStrings(ioHelper));
|
||||
configs.Add<IModelsBuilderConfig>(() => new ModelsBuilderConfig(ioHelper));
|
||||
|
||||
|
||||
configs.Add<IIndexCreatorSettings>(() => IndexCreatorSettings);
|
||||
configs.Add<INuCacheSettings>(() => NuCacheSettings);
|
||||
configs.Add<ITypeFinderSettings>(() => TypeFinderSettings);
|
||||
configs.Add<IRuntimeSettings>(() => RuntimeSettings);
|
||||
configs.Add<IActiveDirectorySettings>(() => ActiveDirectorySettings);
|
||||
configs.Add<IExceptionFilterSettings>(() => ExceptionFilterSettings);
|
||||
|
||||
configs.AddCoreConfigs(ioHelper);
|
||||
return configs;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
{
|
||||
public class ExceptionFilterSettings : IExceptionFilterSettings
|
||||
{
|
||||
public ExceptionFilterSettings()
|
||||
{
|
||||
if (bool.TryParse(ConfigurationManager.AppSettings["Umbraco.Web.DisableModelBindingExceptionFilter"],
|
||||
out var disabled))
|
||||
{
|
||||
Disabled = disabled;
|
||||
}
|
||||
}
|
||||
public bool Disabled { get; }
|
||||
}
|
||||
}
|
||||
@@ -382,6 +382,10 @@ namespace Umbraco.Core.Configuration
|
||||
private string _databaseFactoryServerVersion;
|
||||
public string DatabaseFactoryServerVersion => GetterWithDefaultValue(Constants.AppSettings.Debug.DatabaseFactoryServerVersion, string.Empty, ref _databaseFactoryServerVersion);
|
||||
|
||||
private string _mainDomLock;
|
||||
|
||||
public string MainDomLock => GetterWithDefaultValue(Constants.AppSettings.MainDomLock, string.Empty, ref _mainDomLock);
|
||||
|
||||
private T GetterWithDefaultValue<T>(string appSettingKey, T defaultValue, ref T backingField)
|
||||
{
|
||||
if (backingField != null) return backingField;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
{
|
||||
public class IndexCreatorSettings : IIndexCreatorSettings
|
||||
{
|
||||
public IndexCreatorSettings()
|
||||
{
|
||||
LuceneDirectoryFactory = ConfigurationManager.AppSettings["Umbraco.Examine.LuceneDirectoryFactory"];
|
||||
}
|
||||
|
||||
public string LuceneDirectoryFactory { get; }
|
||||
}
|
||||
}
|
||||
+12
-7
@@ -2,11 +2,11 @@
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Web.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded.Configuration
|
||||
namespace Umbraco.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the models builder configuration.
|
||||
@@ -21,7 +21,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
|
||||
private object _flagOutOfDateModelsLock;
|
||||
private bool _flagOutOfDateModelsConfigured;
|
||||
private bool _flagOutOfDateModels;
|
||||
public const string DefaultModelsNamespace = "Umbraco.Web.PublishedModels";
|
||||
|
||||
|
||||
public string DefaultModelsDirectory => _ioHelper.MapPath("~/App_Data/Models");
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
|
||||
Enable = ConfigurationManager.AppSettings[Prefix + "Enable"] == "true";
|
||||
|
||||
// ensure defaults are initialized for tests
|
||||
ModelsNamespace = DefaultModelsNamespace;
|
||||
ModelsNamespace = Constants.ModelsBuilder.DefaultModelsNamespace;
|
||||
ModelsDirectory = DefaultModelsDirectory;
|
||||
DebugLevel = 0;
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
|
||||
Enable = enable;
|
||||
_modelsMode = modelsMode;
|
||||
|
||||
ModelsNamespace = string.IsNullOrWhiteSpace(modelsNamespace) ? DefaultModelsNamespace : modelsNamespace;
|
||||
ModelsNamespace = string.IsNullOrWhiteSpace(modelsNamespace) ? Constants.ModelsBuilder.DefaultModelsNamespace : modelsNamespace;
|
||||
EnableFactory = enableFactory;
|
||||
_flagOutOfDateModels = flagOutOfDateModels;
|
||||
ModelsDirectory = string.IsNullOrWhiteSpace(modelsDirectory) ? DefaultModelsDirectory : modelsDirectory;
|
||||
@@ -174,8 +174,13 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
var section = (CompilationSection)ConfigurationManager.GetSection("system.web/compilation");
|
||||
return section != null && section.Debug;
|
||||
if (ConfigurationManager.GetSection("system.web/compilation") is ConfigurationSection section &&
|
||||
bool.TryParse(section.ElementInformation.Properties["debug"].Value.ToString(), out var isDebug))
|
||||
{
|
||||
return isDebug;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
{
|
||||
public class NuCacheSettings : INuCacheSettings
|
||||
{
|
||||
public NuCacheSettings()
|
||||
{
|
||||
BTreeBlockSize = ConfigurationManager.AppSettings["Umbraco.Web.PublishedCache.NuCache.BTree.BlockSize"];
|
||||
}
|
||||
public string BTreeBlockSize { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
{
|
||||
public class RuntimeSettings : IRuntimeSettings
|
||||
{
|
||||
public RuntimeSettings()
|
||||
{
|
||||
if (ConfigurationManager.GetSection("system.web/httpRuntime") is ConfigurationSection section)
|
||||
{
|
||||
var maxRequestLengthProperty = section.ElementInformation.Properties["maxRequestLength"];
|
||||
if (maxRequestLengthProperty != null && maxRequestLengthProperty.Value is int requestLength)
|
||||
{
|
||||
MaxRequestLength = requestLength;
|
||||
}
|
||||
|
||||
var maxQueryStringProperty = section.ElementInformation.Properties["maxQueryStringLength"];
|
||||
if (maxQueryStringProperty != null && maxQueryStringProperty.Value is int maxQueryStringLength)
|
||||
{
|
||||
MaxQueryStringLength = maxQueryStringLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
public int? MaxQueryStringLength { get; }
|
||||
public int? MaxRequestLength { get; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
{
|
||||
public class TypeFinderSettings : ITypeFinderSettings
|
||||
{
|
||||
public TypeFinderSettings()
|
||||
{
|
||||
AssembliesAcceptingLoadExceptions = ConfigurationManager.AppSettings[
|
||||
Constants.AppSettings.AssembliesAcceptingLoadExceptions];
|
||||
}
|
||||
|
||||
public string AssembliesAcceptingLoadExceptions { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public interface IActiveDirectorySettings
|
||||
{
|
||||
string ActiveDirectoryDomain { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public interface IExceptionFilterSettings
|
||||
{
|
||||
bool Disabled { get; }
|
||||
}
|
||||
}
|
||||
@@ -95,5 +95,6 @@
|
||||
bool DisableElectionForSingleServer { get; }
|
||||
string RegisterType { get; }
|
||||
string DatabaseFactoryServerVersion { get; }
|
||||
string MainDomLock { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public interface IIndexCreatorSettings
|
||||
{
|
||||
string LuceneDirectoryFactory { get; }
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace Umbraco.ModelsBuilder.Embedded.Configuration
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public interface IModelsBuilderConfig
|
||||
{
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public interface INuCacheSettings
|
||||
{
|
||||
string BTreeBlockSize { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public interface IRuntimeSettings
|
||||
{
|
||||
int? MaxQueryStringLength { get; }
|
||||
int? MaxRequestLength { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public interface ITypeFinderSettings
|
||||
{
|
||||
string AssembliesAcceptingLoadExceptions { get; }
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
namespace Umbraco.ModelsBuilder.Embedded.Configuration
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the models generation modes.
|
||||
@@ -8,7 +8,7 @@
|
||||
/// <summary>
|
||||
/// Do not generate models.
|
||||
/// </summary>
|
||||
Nothing = 0, // default value
|
||||
Nothing = 0, // default value
|
||||
|
||||
/// <summary>
|
||||
/// Generate models in memory.
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
namespace Umbraco.ModelsBuilder.Embedded.Configuration
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides extensions for the <see cref="ModelsMode"/> enumeration.
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
{
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines constants.
|
||||
/// </summary>
|
||||
public static partial class Constants
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines constants for ModelsBuilder.
|
||||
/// </summary>
|
||||
public static class ModelsBuilder
|
||||
{
|
||||
|
||||
public const string DefaultModelsNamespace = "Umbraco.Web.PublishedModels";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@
|
||||
/// The header name that angular uses to pass in the token to validate the cookie
|
||||
/// </summary>
|
||||
public const string AngularHeadername = "X-UMB-XSRF-TOKEN";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using Examine;
|
||||
using Examine.LuceneEngine.Directories;
|
||||
using Lucene.Net.Store;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -19,11 +19,13 @@ namespace Umbraco.Examine
|
||||
{
|
||||
private readonly ITypeFinder _typeFinder;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly IIndexCreatorSettings _settings;
|
||||
|
||||
protected LuceneIndexCreator(ITypeFinder typeFinder, IIOHelper ioHelper)
|
||||
protected LuceneIndexCreator(ITypeFinder typeFinder, IIOHelper ioHelper, IIndexCreatorSettings settings)
|
||||
{
|
||||
_typeFinder = typeFinder;
|
||||
_ioHelper = ioHelper;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public abstract IEnumerable<IIndex> Create();
|
||||
@@ -43,7 +45,8 @@ namespace Umbraco.Examine
|
||||
System.IO.Directory.CreateDirectory(dirInfo.FullName);
|
||||
|
||||
//check if there's a configured directory factory, if so create it and use that to create the lucene dir
|
||||
var configuredDirectoryFactory = ConfigurationManager.AppSettings["Umbraco.Examine.LuceneDirectoryFactory"];
|
||||
var configuredDirectoryFactory = _settings.LuceneDirectoryFactory;
|
||||
|
||||
if (!configuredDirectoryFactory.IsNullOrWhiteSpace())
|
||||
{
|
||||
//this should be a fully qualified type
|
||||
|
||||
@@ -4,6 +4,7 @@ using Umbraco.Core.Services;
|
||||
using Lucene.Net.Analysis.Standard;
|
||||
using Examine.LuceneEngine;
|
||||
using Examine;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -25,7 +26,8 @@ namespace Umbraco.Examine
|
||||
IMemberService memberService,
|
||||
IUmbracoIndexConfig umbracoIndexConfig,
|
||||
IIOHelper ioHelper,
|
||||
IRuntimeState runtimeState) : base(typeFinder, ioHelper)
|
||||
IRuntimeState runtimeState,
|
||||
IIndexCreatorSettings settings) : base(typeFinder, ioHelper, settings)
|
||||
{
|
||||
ProfilingLogger = profilingLogger ?? throw new System.ArgumentNullException(nameof(profilingLogger));
|
||||
LanguageService = languageService ?? throw new System.ArgumentNullException(nameof(languageService));
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
|
||||
namespace Umbraco.Core.Composing.CompositionExtensions
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded.BackOffice
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Web.Editors;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded.BackOffice
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded.BackOffice
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded.BackOffice
|
||||
|
||||
@@ -3,9 +3,10 @@ using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web.Hosting;
|
||||
using Umbraco.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.ModelsBuilder.Embedded.Building;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Web.Editors;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded.Building
|
||||
{
|
||||
@@ -18,6 +19,8 @@ namespace Umbraco.ModelsBuilder.Embedded.Building
|
||||
internal abstract class Builder
|
||||
{
|
||||
|
||||
|
||||
|
||||
private readonly IList<TypeModel> _typeModels;
|
||||
|
||||
protected Dictionary<string, string> ModelsMap { get; } = new Dictionary<string, string>();
|
||||
@@ -209,7 +212,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Building
|
||||
|
||||
// use configured else fallback to default
|
||||
return string.IsNullOrWhiteSpace(Config.ModelsNamespace)
|
||||
? ModelsBuilderConfig.DefaultModelsNamespace
|
||||
? Constants.ModelsBuilder.DefaultModelsNamespace
|
||||
: Config.ModelsNamespace;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded.Building
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded.Building
|
||||
{
|
||||
|
||||
@@ -4,13 +4,14 @@ using System.Reflection;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Umbraco.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.ModelsBuilder.Embedded.BackOffice;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.JavaScript;
|
||||
using Umbraco.Web.Mvc;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.ModelsBuilder.Embedded.Building;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded.Compose
|
||||
{
|
||||
@@ -20,16 +19,12 @@ namespace Umbraco.ModelsBuilder.Embedded.Compose
|
||||
{
|
||||
var isLegacyModelsBuilderInstalled = IsLegacyModelsBuilderInstalled();
|
||||
|
||||
|
||||
composition.Configs.Add<IModelsBuilderConfig>(() => new ModelsBuilderConfig(composition.IOHelper));
|
||||
|
||||
if (isLegacyModelsBuilderInstalled)
|
||||
{
|
||||
ComposeForLegacyModelsBuilder(composition);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
composition.Components().Append<ModelsBuilderComponent>();
|
||||
composition.Register<UmbracoServices>(Lifetime.Singleton);
|
||||
composition.RegisterUnique<ModelsGenerator>();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Web.Hosting;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Configuration;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.ModelsBuilder.Embedded.Building;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Web.Cache;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.IO;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Web.Cache;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded
|
||||
|
||||
@@ -11,12 +11,12 @@ using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Compilation;
|
||||
using System.Web.WebPages.Razor;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.ModelsBuilder.Embedded.Building;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using File = System.IO.File;
|
||||
|
||||
namespace Umbraco.ModelsBuilder.Embedded
|
||||
|
||||
@@ -59,10 +59,6 @@
|
||||
<Compile Include="Building\TypeModel.cs" />
|
||||
<Compile Include="Compose\DisabledModelsBuilderComponent.cs" />
|
||||
<Compile Include="ConfigsExtensions.cs" />
|
||||
<Compile Include="Configuration\IModelsBuilderConfig.cs" />
|
||||
<Compile Include="Configuration\ModelsBuilderConfig.cs" />
|
||||
<Compile Include="Configuration\ModelsMode.cs" />
|
||||
<Compile Include="Configuration\ModelsModeExtensions.cs" />
|
||||
<Compile Include="BackOffice\DashboardReport.cs" />
|
||||
<Compile Include="ImplementPropertyTypeAttribute.cs" />
|
||||
<Compile Include="ModelsBuilderAssemblyAttribute.cs" />
|
||||
@@ -123,6 +119,5 @@
|
||||
<Version>5.2.7</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -1,12 +1,13 @@
|
||||
using System.Configuration;
|
||||
using CSharpTest.Net.Collections;
|
||||
using CSharpTest.Net.Serialization;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
{
|
||||
internal class BTree
|
||||
{
|
||||
public static BPlusTree<int, ContentNodeKit> GetTree(string filepath, bool exists)
|
||||
public static BPlusTree<int, ContentNodeKit> GetTree(string filepath, bool exists, INuCacheSettings settings)
|
||||
{
|
||||
var keySerializer = new PrimitiveSerializer();
|
||||
var valueSerializer = new ContentNodeKitSerializer();
|
||||
@@ -19,7 +20,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
CachePolicy = CachePolicy.None,
|
||||
|
||||
// default is 4096, min 2^9 = 512, max 2^16 = 64K
|
||||
FileBlockSize = GetBlockSize(),
|
||||
FileBlockSize = GetBlockSize(settings),
|
||||
|
||||
// other options?
|
||||
};
|
||||
@@ -32,11 +33,11 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
return tree;
|
||||
}
|
||||
|
||||
private static int GetBlockSize()
|
||||
private static int GetBlockSize(INuCacheSettings settings)
|
||||
{
|
||||
var blockSize = 4096;
|
||||
|
||||
var appSetting = ConfigurationManager.AppSettings["Umbraco.Web.PublishedCache.NuCache.BTree.BlockSize"];
|
||||
var appSetting = settings.BTreeBlockSize;
|
||||
if (appSetting == null)
|
||||
return blockSize;
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly INuCacheSettings _config;
|
||||
|
||||
// volatile because we read it with no lock
|
||||
private volatile bool _isReady;
|
||||
@@ -90,7 +91,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
ITypeFinder typeFinder,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IShortStringHelper shortStringHelper,
|
||||
IIOHelper ioHelper)
|
||||
IIOHelper ioHelper,
|
||||
INuCacheSettings config)
|
||||
: base(publishedSnapshotAccessor, variationContextAccessor)
|
||||
{
|
||||
//if (Interlocked.Increment(ref _singletonCheck) > 1)
|
||||
@@ -111,6 +113,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
_ioHelper = ioHelper;
|
||||
_config = config;
|
||||
|
||||
// we need an Xml serializer here so that the member cache can support XPath,
|
||||
// for members this is done by navigating the serialized-to-xml member
|
||||
@@ -197,8 +200,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
_localMediaDbExists = File.Exists(localMediaDbPath);
|
||||
|
||||
// if both local databases exist then GetTree will open them, else new databases will be created
|
||||
_localContentDb = BTree.GetTree(localContentDbPath, _localContentDbExists);
|
||||
_localMediaDb = BTree.GetTree(localMediaDbPath, _localMediaDbExists);
|
||||
_localContentDb = BTree.GetTree(localContentDbPath, _localContentDbExists, _config);
|
||||
_localMediaDb = BTree.GetTree(localMediaDbPath, _localMediaDbExists, _config);
|
||||
|
||||
_logger.Info<PublishedSnapshotService>("Registered with MainDom, localContentDbExists? {LocalContentDbExists}, localMediaDbExists? {LocalMediaDbExists}", _localContentDbExists, _localMediaDbExists);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.ModelsBuilder.Embedded;
|
||||
using Umbraco.ModelsBuilder.Embedded.Building;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
|
||||
namespace Umbraco.Tests.ModelsBuilder
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Configuration;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
namespace Umbraco.Tests.ModelsBuilder
|
||||
@@ -26,7 +27,7 @@ namespace Umbraco.Tests.ModelsBuilder
|
||||
public void DefaultModelsNamespace()
|
||||
{
|
||||
var config = new ModelsBuilderConfig(TestHelper.IOHelper);
|
||||
Assert.AreEqual(ModelsBuilderConfig.DefaultModelsNamespace, config.ModelsNamespace);
|
||||
Assert.AreEqual(Constants.ModelsBuilder.DefaultModelsNamespace, config.ModelsNamespace);
|
||||
}
|
||||
|
||||
[TestCase("c:/path/to/root", "~/dir/models", false, "c:\\path\\to\\root\\dir\\models")]
|
||||
|
||||
@@ -144,6 +144,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
_source = new TestDataSource(kits);
|
||||
|
||||
var typeFinder = new TypeFinder(Mock.Of<ILogger>());
|
||||
var settings = Mock.Of<INuCacheSettings>();
|
||||
|
||||
|
||||
// at last, create the complete NuCache snapshot service!
|
||||
@@ -169,7 +170,8 @@ namespace Umbraco.Tests.PublishedContent
|
||||
typeFinder,
|
||||
hostingEnvironment,
|
||||
new MockShortStringHelper(),
|
||||
TestHelper.IOHelper);
|
||||
TestHelper.IOHelper,
|
||||
settings);
|
||||
|
||||
// invariant is the current default
|
||||
_variationAccesor.VariationContext = new VariationContext();
|
||||
|
||||
@@ -185,6 +185,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
_variationAccesor = new TestVariationContextAccessor();
|
||||
|
||||
var typeFinder = new TypeFinder(Mock.Of<ILogger>());
|
||||
var settings = Mock.Of<INuCacheSettings>();
|
||||
|
||||
// at last, create the complete NuCache snapshot service!
|
||||
var options = new PublishedSnapshotServiceOptions { IgnoreLocalDb = true };
|
||||
@@ -209,7 +210,8 @@ namespace Umbraco.Tests.PublishedContent
|
||||
typeFinder,
|
||||
TestHelper.GetHostingEnvironment(),
|
||||
new MockShortStringHelper(),
|
||||
TestHelper.IOHelper);
|
||||
TestHelper.IOHelper,
|
||||
settings);
|
||||
|
||||
// invariant is the current default
|
||||
_variationAccesor.VariationContext = new VariationContext();
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Internal;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
@@ -17,22 +15,17 @@ using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.WebApi;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Dictionary;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.PublishedContent;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.Runtime;
|
||||
using Umbraco.Web.Security;
|
||||
using Current = Umbraco.Web.Composing.Current;
|
||||
using Umbraco.Web.Security.Providers;
|
||||
using ILogger = Umbraco.Core.Logging.ILogger;
|
||||
|
||||
namespace Umbraco.Tests.Routing
|
||||
@@ -141,7 +134,7 @@ namespace Umbraco.Tests.Routing
|
||||
var url = "~/dummy-page";
|
||||
var template = CreateTemplate(templateName);
|
||||
var route = RouteTable.Routes["Umbraco_default"];
|
||||
var routeData = new RouteData() {Route = route};
|
||||
var routeData = new RouteData() { Route = route };
|
||||
var umbracoContext = GetUmbracoContext("~/dummy-page", template.Id, routeData, true);
|
||||
var httpContext = GetHttpContextFactory(url, routeData).HttpContext;
|
||||
var publishedRouter = CreatePublishedRouter();
|
||||
@@ -155,6 +148,7 @@ namespace Umbraco.Tests.Routing
|
||||
|
||||
var handler = new RenderRouteHandler(umbracoContext, new TestControllerFactory(umbracoContextAccessor, Mock.Of<ILogger>(), context =>
|
||||
{
|
||||
|
||||
return new CustomDocumentController(Factory.GetInstance<IGlobalSettings>(),
|
||||
umbracoContextAccessor,
|
||||
Factory.GetInstance<ServiceContext>(),
|
||||
|
||||
@@ -86,6 +86,7 @@ namespace Umbraco.Tests.Scoping
|
||||
var hostingEnvironment = TestHelper.GetHostingEnvironment();
|
||||
|
||||
var typeFinder = new TypeFinder(Mock.Of<ILogger>());
|
||||
var settings = Mock.Of<INuCacheSettings>();
|
||||
|
||||
return new PublishedSnapshotService(
|
||||
options,
|
||||
@@ -107,7 +108,8 @@ namespace Umbraco.Tests.Scoping
|
||||
typeFinder,
|
||||
hostingEnvironment,
|
||||
new MockShortStringHelper(),
|
||||
IOHelper);
|
||||
IOHelper,
|
||||
settings);
|
||||
}
|
||||
|
||||
protected IUmbracoContext GetUmbracoContextNu(string url, int templateId = 1234, RouteData routeData = null, bool setSingleton = false, IUmbracoSettingsSection umbracoSettings = null, IEnumerable<IUrlProvider> urlProviders = null)
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace Umbraco.Tests.Services
|
||||
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
|
||||
|
||||
var typeFinder = new TypeFinder(Mock.Of<ILogger>());
|
||||
var settings = Mock.Of<INuCacheSettings>();
|
||||
|
||||
return new PublishedSnapshotService(
|
||||
options,
|
||||
@@ -80,7 +81,8 @@ namespace Umbraco.Tests.Services
|
||||
typeFinder,
|
||||
hostingEnvironment,
|
||||
new MockShortStringHelper(),
|
||||
IOHelper);
|
||||
IOHelper,
|
||||
settings);
|
||||
}
|
||||
|
||||
public class LocalServerMessenger : ServerMessengerBase
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
redirectUrl = Url.Action("AuthorizeUpgrade", "BackOffice")
|
||||
});
|
||||
}
|
||||
@Html.BareMinimumServerVariablesScript(Url, externalLoginUrl, Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.UmbracoSettingsSection, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment)
|
||||
@Html.BareMinimumServerVariablesScript(Url, externalLoginUrl, Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.UmbracoSettingsSection, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment, Model.RuntimeSettings)
|
||||
|
||||
<script type="text/javascript">
|
||||
document.angularReady = function (app) {
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
on-login="hideLoginScreen()">
|
||||
</umb-login>
|
||||
|
||||
@Html.BareMinimumServerVariablesScript(Url, Url.Action("ExternalLogin", "BackOffice", new { area = ViewData.GetUmbracoPath() }), Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.UmbracoSettingsSection, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment)
|
||||
@Html.BareMinimumServerVariablesScript(Url, Url.Action("ExternalLogin", "BackOffice", new { area = ViewData.GetUmbracoPath() }), Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.UmbracoSettingsSection, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment, Model.RuntimeSettings)
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Compilation;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Hosting;
|
||||
@@ -26,7 +23,11 @@ namespace Umbraco.Web.Composing
|
||||
internal class BuildManagerTypeFinder : TypeFinder, ITypeFinder
|
||||
{
|
||||
|
||||
public BuildManagerTypeFinder(IIOHelper ioHelper, IHostingEnvironment hostingEnvironment, ILogger logger, ITypeFinderConfig typeFinderConfig = null) : base(logger, typeFinderConfig)
|
||||
public BuildManagerTypeFinder(
|
||||
IIOHelper ioHelper,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
ILogger logger,
|
||||
ITypeFinderConfig typeFinderConfig = null) : base(logger, typeFinderConfig)
|
||||
{
|
||||
if (ioHelper == null) throw new ArgumentNullException(nameof(ioHelper));
|
||||
if (hostingEnvironment == null) throw new ArgumentNullException(nameof(hostingEnvironment));
|
||||
@@ -91,7 +92,14 @@ namespace Umbraco.Web.Composing
|
||||
/// </summary>
|
||||
internal class TypeFinderConfig : ITypeFinderConfig
|
||||
{
|
||||
private readonly ITypeFinderSettings _settings;
|
||||
private IEnumerable<string> _assembliesAcceptingLoadExceptions;
|
||||
|
||||
public TypeFinderConfig(ITypeFinderSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public IEnumerable<string> AssembliesAcceptingLoadExceptions
|
||||
{
|
||||
get
|
||||
@@ -99,7 +107,7 @@ namespace Umbraco.Web.Composing
|
||||
if (_assembliesAcceptingLoadExceptions != null)
|
||||
return _assembliesAcceptingLoadExceptions;
|
||||
|
||||
var s = ConfigurationManager.AppSettings[Constants.AppSettings.AssembliesAcceptingLoadExceptions];
|
||||
var s = _settings.AssembliesAcceptingLoadExceptions;
|
||||
return _assembliesAcceptingLoadExceptions = string.IsNullOrWhiteSpace(s)
|
||||
? Array.Empty<string>()
|
||||
: s.Split(',').Select(x => x.Trim()).ToArray();
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace Umbraco.Web.Editors
|
||||
private readonly TreeCollection _treeCollection;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IRuntimeSettings _runtimeSettings;
|
||||
|
||||
public BackOfficeController(
|
||||
IManifestParser manifestParser,
|
||||
@@ -69,8 +70,10 @@ namespace Umbraco.Web.Editors
|
||||
IIOHelper ioHelper,
|
||||
TreeCollection treeCollection,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IRuntimeSettings settings)
|
||||
: base(globalSettings, umbracoContextAccessor, services, appCaches, profilingLogger)
|
||||
|
||||
{
|
||||
_manifestParser = manifestParser;
|
||||
_features = features;
|
||||
@@ -82,6 +85,7 @@ namespace Umbraco.Web.Editors
|
||||
_treeCollection = treeCollection ?? throw new ArgumentNullException(nameof(treeCollection));
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_runtimeSettings = settings;
|
||||
}
|
||||
|
||||
protected BackOfficeSignInManager SignInManager => _signInManager ?? (_signInManager = OwinContext.GetBackOfficeSignInManager());
|
||||
@@ -97,8 +101,8 @@ namespace Umbraco.Web.Editors
|
||||
public async Task<ActionResult> Default()
|
||||
{
|
||||
return await RenderDefaultOrProcessExternalLoginAsync(
|
||||
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection,_ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment)),
|
||||
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment)));
|
||||
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection,_ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings)),
|
||||
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings)));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@@ -181,7 +185,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
return await RenderDefaultOrProcessExternalLoginAsync(
|
||||
//The default view to render when there is no external login info or errors
|
||||
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/AuthorizeUpgrade.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment)),
|
||||
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/AuthorizeUpgrade.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings)),
|
||||
//The ActionResult to perform if external login is successful
|
||||
() => Redirect("/"));
|
||||
}
|
||||
@@ -288,7 +292,7 @@ namespace Umbraco.Web.Editors
|
||||
[MinifyJavaScriptResult(Order = 1)]
|
||||
public JavaScriptResult ServerVariables()
|
||||
{
|
||||
var serverVars = new BackOfficeServerVariables(Url, _runtimeState, _features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment);
|
||||
var serverVars = new BackOfficeServerVariables(Url, _runtimeState, _features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings);
|
||||
|
||||
//cache the result if debugging is disabled
|
||||
var result = _hostingEnvironment.IsDebugMode
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
public class BackOfficeModel
|
||||
{
|
||||
public BackOfficeModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment)
|
||||
public BackOfficeModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment, IRuntimeSettings runtimeSettings)
|
||||
{
|
||||
Features = features;
|
||||
GlobalSettings = globalSettings;
|
||||
@@ -20,6 +20,7 @@ namespace Umbraco.Web.Editors
|
||||
TreeCollection = treeCollection;
|
||||
HttpContextAccessor = httpContextAccessor;
|
||||
HostingEnvironment = hostingEnvironment;
|
||||
RuntimeSettings = runtimeSettings;
|
||||
}
|
||||
|
||||
public UmbracoFeatures Features { get; }
|
||||
@@ -30,5 +31,6 @@ namespace Umbraco.Web.Editors
|
||||
public TreeCollection TreeCollection { get; }
|
||||
public IHttpContextAccessor HttpContextAccessor { get; }
|
||||
public IHostingEnvironment HostingEnvironment { get; }
|
||||
public IRuntimeSettings RuntimeSettings { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace Umbraco.Web.Editors
|
||||
private readonly UmbracoFeatures _features;
|
||||
public IEnumerable<ILanguage> Languages { get; }
|
||||
|
||||
public BackOfficePreviewModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IEnumerable<ILanguage> languages, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment)
|
||||
: base(features, globalSettings, umbracoVersion, umbracoSettingsSection, ioHelper, treeCollection, httpContextAccessor, hostingEnvironment)
|
||||
public BackOfficePreviewModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IEnumerable<ILanguage> languages, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment, IRuntimeSettings runtimeSettings)
|
||||
: base(features, globalSettings, umbracoVersion, umbracoSettingsSection, ioHelper, treeCollection, httpContextAccessor, hostingEnvironment, runtimeSettings)
|
||||
{
|
||||
_features = features;
|
||||
Languages = languages;
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Mvc;
|
||||
using ClientDependency.Core.Config;
|
||||
using Microsoft.Owin;
|
||||
using Microsoft.Owin.Security;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
@@ -41,8 +38,20 @@ namespace Umbraco.Web.Editors
|
||||
private readonly TreeCollection _treeCollection;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IRuntimeSettings _settings;
|
||||
|
||||
internal BackOfficeServerVariables(UrlHelper urlHelper, IRuntimeState runtimeState, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment)
|
||||
internal BackOfficeServerVariables(
|
||||
UrlHelper urlHelper,
|
||||
IRuntimeState runtimeState,
|
||||
UmbracoFeatures features,
|
||||
IGlobalSettings globalSettings,
|
||||
IUmbracoVersion umbracoVersion,
|
||||
IUmbracoSettingsSection umbracoSettingsSection,
|
||||
IIOHelper ioHelper,
|
||||
TreeCollection treeCollection,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IRuntimeSettings settings)
|
||||
{
|
||||
_urlHelper = urlHelper;
|
||||
_runtimeState = runtimeState;
|
||||
@@ -54,6 +63,7 @@ namespace Umbraco.Web.Editors
|
||||
_treeCollection = treeCollection ?? throw new ArgumentNullException(nameof(treeCollection));
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -473,11 +483,9 @@ namespace Umbraco.Web.Editors
|
||||
return app;
|
||||
}
|
||||
|
||||
private static string GetMaxRequestLength()
|
||||
private string GetMaxRequestLength()
|
||||
{
|
||||
return ConfigurationManager.GetSection("system.web/httpRuntime") is HttpRuntimeSection section
|
||||
? section.MaxRequestLength.ToString()
|
||||
: string.Empty;
|
||||
return _settings.MaxRequestLength.HasValue ? _settings.MaxRequestLength.Value.ToString() : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace Umbraco.Web.Editors
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly ICookieManager _cookieManager;
|
||||
private IRuntimeSettings _runtimeSettings;
|
||||
|
||||
public PreviewController(
|
||||
UmbracoFeatures features,
|
||||
@@ -49,7 +50,8 @@ namespace Umbraco.Web.Editors
|
||||
TreeCollection treeCollection,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
ICookieManager cookieManager)
|
||||
ICookieManager cookieManager,
|
||||
IRuntimeSettings settings)
|
||||
{
|
||||
_features = features;
|
||||
_globalSettings = globalSettings;
|
||||
@@ -63,6 +65,7 @@ namespace Umbraco.Web.Editors
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_cookieManager = cookieManager;
|
||||
_runtimeSettings = settings;
|
||||
}
|
||||
|
||||
[UmbracoAuthorize(redirectToUmbracoLogin: true)]
|
||||
@@ -71,7 +74,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
var availableLanguages = _localizationService.GetAllLanguages();
|
||||
|
||||
var model = new BackOfficePreviewModel(_features, _globalSettings, _umbracoVersion, availableLanguages, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment);
|
||||
var model = new BackOfficePreviewModel(_features, _globalSettings, _umbracoVersion, availableLanguages, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings);
|
||||
|
||||
if (model.PreviewExtendedHeaderView.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
|
||||
@@ -40,9 +40,9 @@ namespace Umbraco.Web
|
||||
/// These are the bare minimal server variables that are required for the application to start without being authenticated,
|
||||
/// we will load the rest of the server vars after the user is authenticated.
|
||||
/// </remarks>
|
||||
public static IHtmlString BareMinimumServerVariablesScript(this HtmlHelper html, UrlHelper uri, string externalLoginsUrl, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment)
|
||||
public static IHtmlString BareMinimumServerVariablesScript(this HtmlHelper html, UrlHelper uri, string externalLoginsUrl, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment, IRuntimeSettings settings)
|
||||
{
|
||||
var serverVars = new BackOfficeServerVariables(uri, Current.RuntimeState, features, globalSettings, umbracoVersion, umbracoSettingsSection, ioHelper, treeCollection, httpContextAccessor, hostingEnvironment);
|
||||
var serverVars = new BackOfficeServerVariables(uri, Current.RuntimeState, features, globalSettings, umbracoVersion, umbracoSettingsSection, ioHelper, treeCollection, httpContextAccessor, hostingEnvironment, settings);
|
||||
var minVars = serverVars.BareMinimumServerVariables();
|
||||
|
||||
var str = @"<script type=""text/javascript"">
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Configuration;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web.Mvc;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Composing;
|
||||
|
||||
@@ -21,8 +22,10 @@ namespace Umbraco.Web.Mvc
|
||||
|
||||
public void OnException(ExceptionContext filterContext)
|
||||
{
|
||||
var settings = Current.Factory.GetInstance<IExceptionFilterSettings>();
|
||||
var disabled = settings?.Disabled ?? false;
|
||||
if (Current.PublishedModelFactory.IsLiveFactory()
|
||||
&& ConfigurationManager.AppSettings["Umbraco.Web.DisableModelBindingExceptionFilter"] != "true"
|
||||
&& !disabled
|
||||
&& !filterContext.ExceptionHandled
|
||||
&& ((filterContext.Exception is ModelBindingException || filterContext.Exception is InvalidCastException)
|
||||
&& IsMessageAboutTheSameModelType(filterContext.Exception.Message)))
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.Dispatcher;
|
||||
using System.Web.Mvc;
|
||||
@@ -17,7 +15,6 @@ using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.Install;
|
||||
using Umbraco.Web.JavaScript;
|
||||
using Umbraco.Web.Mvc;
|
||||
@@ -37,6 +34,7 @@ namespace Umbraco.Web.Runtime
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
private readonly IRuntimeSettings _settings;
|
||||
|
||||
public WebInitialComponent(
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
@@ -46,7 +44,8 @@ namespace Umbraco.Web.Runtime
|
||||
IGlobalSettings globalSettings,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IIOHelper ioHelper,
|
||||
IShortStringHelper shortStringHelper)
|
||||
IShortStringHelper shortStringHelper,
|
||||
IRuntimeSettings settings)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_surfaceControllerTypes = surfaceControllerTypes;
|
||||
@@ -56,6 +55,7 @@ namespace Umbraco.Web.Runtime
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_ioHelper = ioHelper;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
@@ -146,10 +146,10 @@ namespace Umbraco.Web.Runtime
|
||||
= Path.Combine(cachePath, "ClientDependency");
|
||||
}
|
||||
|
||||
if (ConfigurationManager.GetSection("system.web/httpRuntime") is HttpRuntimeSection section)
|
||||
if (_settings.MaxQueryStringLength.HasValue || _settings.MaxRequestLength.HasValue)
|
||||
{
|
||||
//set the max url length for CDF to be the smallest of the max query length, max request length
|
||||
ClientDependency.Core.CompositeFiles.CompositeDependencyHandler.MaxHandlerUrlLength = Math.Min(section.MaxQueryStringLength, section.MaxRequestLength);
|
||||
ClientDependency.Core.CompositeFiles.CompositeDependencyHandler.MaxHandlerUrlLength = Math.Min(_settings.MaxQueryStringLength.GetValueOrDefault(), _settings.MaxRequestLength.GetValueOrDefault());
|
||||
}
|
||||
|
||||
//Register a custom renderer - used to process property editor dependencies
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web;
|
||||
using Umbraco.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
@@ -97,7 +97,7 @@ namespace Umbraco.Web.Runtime
|
||||
|
||||
#region Getters
|
||||
|
||||
protected override ITypeFinder GetTypeFinder() => _typeFinder ?? (_typeFinder = new BuildManagerTypeFinder(IOHelper, HostingEnvironment, Logger, new BuildManagerTypeFinder.TypeFinderConfig()));
|
||||
protected override ITypeFinder GetTypeFinder() => _typeFinder ?? (_typeFinder = new BuildManagerTypeFinder(IOHelper, HostingEnvironment, Logger, new BuildManagerTypeFinder.TypeFinderConfig(new TypeFinderSettings())));
|
||||
|
||||
protected override AppCaches GetAppCaches() => new AppCaches(
|
||||
// we need to have the dep clone runtime cache provider to ensure
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.DirectoryServices.AccountManagement;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core.Models.Identity;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Web.Models.Identity;
|
||||
|
||||
namespace Umbraco.Web.Security
|
||||
@@ -10,15 +9,15 @@ namespace Umbraco.Web.Security
|
||||
// TODO: This relies on an assembly that is not .NET Standard (at least not at the time of implementation) :(
|
||||
public class ActiveDirectoryBackOfficeUserPasswordChecker : IBackOfficeUserPasswordChecker
|
||||
{
|
||||
public virtual string ActiveDirectoryDomain
|
||||
private readonly IActiveDirectorySettings _settings;
|
||||
|
||||
public ActiveDirectoryBackOfficeUserPasswordChecker(IActiveDirectorySettings settings)
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: Verify this AppSetting key is used in .NET Framework & canot be changed to Umbraco.Core. prefix
|
||||
return ConfigurationManager.AppSettings["ActiveDirectoryDomain"];
|
||||
}
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public virtual string ActiveDirectoryDomain => _settings.ActiveDirectoryDomain;
|
||||
|
||||
public Task<BackOfficeUserPasswordCheckerResult> CheckPasswordAsync(BackOfficeIdentityUser user, string password)
|
||||
{
|
||||
bool isValid;
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
using System.Configuration;
|
||||
using System.Threading;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging.Serilog;
|
||||
using Umbraco.Core.Runtime;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Web.Runtime;
|
||||
|
||||
namespace Umbraco.Web
|
||||
@@ -26,8 +23,7 @@ namespace Umbraco.Web
|
||||
var dbProviderFactoryCreator = new UmbracoDbProviderFactoryCreator(connectionStringConfig?.ProviderName);
|
||||
|
||||
// Determine if we should use the sql main dom or the default
|
||||
var appSettingMainDomLock = ConfigurationManager.AppSettings[Constants.AppSettings.MainDomLock];
|
||||
|
||||
var appSettingMainDomLock = configs.Global().MainDomLock;
|
||||
var mainDomLock = appSettingMainDomLock == "SqlMainDomLock"
|
||||
? (IMainDomLock)new SqlMainDomLock(logger, configs, dbProviderFactoryCreator)
|
||||
: new MainDomSemaphoreLock(logger, hostingEnvironment);
|
||||
|
||||
+3
-3
@@ -111,11 +111,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Persistance.SqlCe",
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.TestData", "Umbraco.TestData\Umbraco.TestData.csproj", "{FB5676ED-7A69-492C-B802-E7B24144C0FC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.PublishedCache.NuCache", "Umbraco.PublishedCache.NuCache\Umbraco.PublishedCache.NuCache.csproj", "{F6DE8DA0-07CC-4EF2-8A59-2BC81DBB3830}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.PublishedCache.NuCache", "Umbraco.PublishedCache.NuCache\Umbraco.PublishedCache.NuCache.csproj", "{F6DE8DA0-07CC-4EF2-8A59-2BC81DBB3830}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Examine.Lucene", "Umbraco.Examine.Lucene\Umbraco.Examine.Lucene.csproj", "{0FAD7D2A-D7DD-45B1-91FD-488BB6CDACEA}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Examine.Lucene", "Umbraco.Examine.Lucene\Umbraco.Examine.Lucene.csproj", "{0FAD7D2A-D7DD-45B1-91FD-488BB6CDACEA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Web.BackOffice", "Umbraco.Web.BackOffice\Umbraco.Web.BackOffice.csproj", "{9B95EEF7-63FE-4432-8C63-166BE9C1A929}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Web.BackOffice", "Umbraco.Web.BackOffice\Umbraco.Web.BackOffice.csproj", "{9B95EEF7-63FE-4432-8C63-166BE9C1A929}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
||||
Reference in New Issue
Block a user