diff --git a/src/Umbraco.Core/Components/BootLoader.cs b/src/Umbraco.Core/Components/BootLoader.cs index efd29a24da..8af6da0f69 100644 --- a/src/Umbraco.Core/Components/BootLoader.cs +++ b/src/Umbraco.Core/Components/BootLoader.cs @@ -6,7 +6,6 @@ using System.Text; using LightInject; using Umbraco.Core.Exceptions; using Umbraco.Core.Logging; -using Umbraco.Core.Persistence; using Umbraco.Core.Scoping; namespace Umbraco.Core.Components diff --git a/src/Umbraco.Core/EnumerableExtensions.cs b/src/Umbraco.Core/EnumerableExtensions.cs index de8ff22e15..d5d4a66122 100644 --- a/src/Umbraco.Core/EnumerableExtensions.cs +++ b/src/Umbraco.Core/EnumerableExtensions.cs @@ -92,13 +92,6 @@ namespace Umbraco.Core } } - [EditorBrowsable(EditorBrowsableState.Never)] - [Obsolete("Use a normal foreach loop instead, this adds more allocations than necessary")] - public static TResult[] ForEach(this IEnumerable items, Func func) - { - return items.Select(func).ToArray(); - } - [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("Use a normal foreach loop instead, this adds more allocations than necessary")] public static IEnumerable ForEach(this IEnumerable items, Action action) diff --git a/src/Umbraco.Core/Persistence/SqlContext.cs b/src/Umbraco.Core/Persistence/SqlContext.cs index 8bf59b7d24..feb92e0849 100644 --- a/src/Umbraco.Core/Persistence/SqlContext.cs +++ b/src/Umbraco.Core/Persistence/SqlContext.cs @@ -30,11 +30,26 @@ namespace Umbraco.Core.Persistence Templates = new SqlTemplates(this); } - /// - public ISqlSyntaxProvider SqlSyntax { get; } + // fixme + internal SqlContext() + { } + + internal void Initialize(ISqlSyntaxProvider sqlSyntax, DatabaseType databaseType, IPocoDataFactory pocoDataFactory, IMapperCollection mappers = null) + { + // for tests + Mappers = mappers ?? new Mappers.MapperCollection(Enumerable.Empty()); + + SqlSyntax = sqlSyntax ?? throw new ArgumentNullException(nameof(sqlSyntax)); + PocoDataFactory = pocoDataFactory ?? throw new ArgumentNullException(nameof(pocoDataFactory)); + DatabaseType = databaseType ?? throw new ArgumentNullException(nameof(databaseType)); + Templates = new SqlTemplates(this); + } /// - public DatabaseType DatabaseType { get; } + public ISqlSyntaxProvider SqlSyntax { get; private set; } + + /// + public DatabaseType DatabaseType { get; private set; } /// public Sql Sql() => NPoco.Sql.BuilderFor((ISqlContext) this); @@ -46,12 +61,12 @@ namespace Umbraco.Core.Persistence public IQuery Query() => new Query(this); /// - public SqlTemplates Templates { get; } + public SqlTemplates Templates { get; private set; } /// - public IPocoDataFactory PocoDataFactory { get; } + public IPocoDataFactory PocoDataFactory { get; private set; } /// - public IMapperCollection Mappers { get; } + public IMapperCollection Mappers { get; private set; } } } diff --git a/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs b/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs index 5e5451c644..d95b590be8 100644 --- a/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs +++ b/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs @@ -29,6 +29,8 @@ namespace Umbraco.Core.Persistence private readonly ISqlSyntaxProvider[] _sqlSyntaxProviders; private readonly IMapperCollection _mappers; private readonly ILogger _logger; + private readonly SqlContext _sqlContext = new SqlContext(); + private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(); private DatabaseFactory _npocoDatabaseFactory; private IPocoDataFactory _pocoDataFactory; @@ -37,10 +39,8 @@ namespace Umbraco.Core.Persistence private DbProviderFactory _dbProviderFactory; private DatabaseType _databaseType; private ISqlSyntaxProvider _sqlSyntax; - private ISqlContext _sqlContext; private RetryPolicy _connectionRetryPolicy; private RetryPolicy _commandRetryPolicy; - private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(); #region Ctor @@ -114,14 +114,7 @@ namespace Umbraco.Core.Persistence #region IDatabaseContext /// - public ISqlContext SqlContext - { - get - { - EnsureConfigured(); - return _sqlContext; - } - } + public ISqlContext SqlContext => _sqlContext; #endregion @@ -168,10 +161,9 @@ namespace Umbraco.Core.Persistence if (_npocoDatabaseFactory == null) throw new NullReferenceException("The call to UmbracoDatabaseFactory.Config yielded a null UmbracoDatabaseFactory instance."); - // these are created here because it is the UmbracoDatabaseFactory that determines - // the sql syntax, poco data factory, and database type - so it "owns" the context - // and the query factory - _sqlContext = new SqlContext(_sqlSyntax, _databaseType, _pocoDataFactory, _mappers); + // can initialize now because it is the UmbracoDatabaseFactory that determines + // the sql syntax, poco data factory, and database type + _sqlContext.Initialize(_sqlSyntax, _databaseType, _pocoDataFactory, _mappers); _logger.Debug("Configured."); Configured = true; @@ -203,11 +195,17 @@ namespace Umbraco.Core.Persistence // ensures that the database is configured, else throws private void EnsureConfigured() { - using (new ReadLock(_lock)) // fixme - bad, allocations! + _lock.EnterReadLock(); + try { if (Configured == false) throw new InvalidOperationException("Not configured."); } + finally + { + if (_lock.IsReadLockHeld) + _lock.ExitReadLock(); + } } // method used by NPoco's UmbracoDatabaseFactory to actually create the database instance diff --git a/src/Umbraco.Tests/Facade/NestedContentTests.cs b/src/Umbraco.Tests/Facade/NestedContentTests.cs index ff41f883c3..a127e739a4 100644 --- a/src/Umbraco.Tests/Facade/NestedContentTests.cs +++ b/src/Umbraco.Tests/Facade/NestedContentTests.cs @@ -113,10 +113,11 @@ namespace Umbraco.Tests.Facade .Returns((PublishedPropertyType propertyType, IPublishedElement element, bool preview, PropertyCacheLevel referenceCacheLevel, object source) => new TestPublishedProperty(propertyType, element, preview, referenceCacheLevel, source)); + var lazyFacadeService = new Lazy(() => facadeService.Object); var converters = new PropertyValueConverterCollection(new IPropertyValueConverter[] { - new NestedContentSingleValueConverter(facadeAccessor.Object, facadeService.Object, publishedModelFactory.Object, proflog), - new NestedContentManyValueConverter(facadeAccessor.Object, facadeService.Object, publishedModelFactory.Object, proflog), + new NestedContentSingleValueConverter(facadeAccessor.Object, lazyFacadeService, publishedModelFactory.Object, proflog), + new NestedContentManyValueConverter(facadeAccessor.Object, lazyFacadeService, publishedModelFactory.Object, proflog), }); var propertyType1 = new PublishedPropertyType("property1", 1, Constants.PropertyEditors.NestedContentAlias, converters); diff --git a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs index a4ee1f37d2..dcaf254658 100644 --- a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs @@ -272,9 +272,11 @@ namespace Umbraco.Tests.Services ServiceContext.ContentTypeService.Save(contentType1); ServiceContext.ContentTypeService.Save(contentType2); var contentItems1 = MockedContent.CreateTextpageContent(contentType1, -1, 10).ToArray(); - contentItems1.ForEach(x => ServiceContext.ContentService.SaveAndPublishWithStatus(x)); + foreach (var x in contentItems1) + ServiceContext.ContentService.SaveAndPublishWithStatus(x); var contentItems2 = MockedContent.CreateTextpageContent(contentType2, -1, 5).ToArray(); - contentItems2.ForEach(x => ServiceContext.ContentService.SaveAndPublishWithStatus(x)); + foreach (var x in contentItems2) + ServiceContext.ContentService.SaveAndPublishWithStatus(x); //only update the contentType1 alias which will force an xml rebuild for all content of that type contentType1.Alias = "newAlias"; ServiceContext.ContentTypeService.Save(contentType1); @@ -305,7 +307,8 @@ namespace Umbraco.Tests.Services var contentType1 = MockedContentTypes.CreateTextpageContentType("test1", "Test1"); ServiceContext.ContentTypeService.Save(contentType1); var contentItems1 = MockedContent.CreateTextpageContent(contentType1, -1, 10).ToArray(); - contentItems1.ForEach(x => ServiceContext.ContentService.SaveAndPublishWithStatus(x)); + foreach (var x in contentItems1) + ServiceContext.ContentService.SaveAndPublishWithStatus(x); var alias = contentType1.PropertyTypes.First().Alias; var elementToMatch = "<" + alias + ">"; diff --git a/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs b/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs index e225b1ae10..62674e039f 100644 --- a/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs +++ b/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs @@ -311,7 +311,8 @@ namespace Umbraco.Tests.TestHelpers.Entities { var contentType = CreateSimpleContentType(alias, name, groupedCollection); //now add the non-grouped properties - nonGroupedCollection.ForEach(pt => contentType.AddPropertyType(pt)); + foreach (var x in nonGroupedCollection) + contentType.AddPropertyType(x); //ensure that nothing is marked as dirty contentType.ResetDirtyProperties(false); diff --git a/src/Umbraco.Web.UI.Client/src/installer/steps/user.html b/src/Umbraco.Web.UI.Client/src/installer/steps/user.html index 68958be0a6..8c0989457d 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/steps/user.html +++ b/src/Umbraco.Web.UI.Client/src/installer/steps/user.html @@ -1,7 +1,7 @@
-

Install Umbraco 7

+

Install Umbraco 8 (alpha)

-

Enter your name, email and password to install Umbraco 7 with its default settings, alternatively you can customize your installation

+

Enter your name, email and password to install Umbraco 8 with its default settings, alternatively you can customize your installation

diff --git a/src/Umbraco.Web.UI/Views/Web.config b/src/Umbraco.Web.UI/Views/Web.config index 4fb1030584..9a97ba5be2 100644 --- a/src/Umbraco.Web.UI/Views/Web.config +++ b/src/Umbraco.Web.UI/Views/Web.config @@ -21,9 +21,8 @@ - - + diff --git a/src/Umbraco.Web.UI/web.Template.config b/src/Umbraco.Web.UI/web.Template.config index 9aa207e0e3..7169c3cabc 100644 --- a/src/Umbraco.Web.UI/web.Template.config +++ b/src/Umbraco.Web.UI/web.Template.config @@ -133,7 +133,7 @@ - + diff --git a/src/Umbraco.Web/Editors/SectionController.cs b/src/Umbraco.Web/Editors/SectionController.cs index d2fd5f3231..d77f923c9a 100644 --- a/src/Umbraco.Web/Editors/SectionController.cs +++ b/src/Umbraco.Web/Editors/SectionController.cs @@ -3,6 +3,7 @@ using AutoMapper; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Mvc; using System.Linq; +using Umbraco.Core.Composing; using Umbraco.Core.Models; using Umbraco.Web.Trees; using Section = Umbraco.Web.Models.ContentEditing.Section; @@ -25,20 +26,21 @@ namespace Umbraco.Web.Editors //Check if there are empty dashboards or dashboards that will end up empty based on the current user's access //and add the meta data about them var dashboardHelper = new DashboardHelper(Services.SectionService); - //this is a bit nasty since we'll be proxying via the app tree controller but we sort of have to do that - //since tree's by nature are controllers and require request contextual data. - var appTreeController = new ApplicationTreeController - { - ControllerContext = ControllerContext - }; + + // this is a bit nasty since we'll be proxying via the app tree controller but we sort of have to do that + // since tree's by nature are controllers and require request contextual data - and then we have to + // remember to inject properties - nasty indeed + var appTreeController = new ApplicationTreeController(); + Current.Container.InjectProperties(appTreeController); + appTreeController.ControllerContext = ControllerContext; + var dashboards = dashboardHelper.GetDashboards(Security.CurrentUser); //now we can add metadata for each section so that the UI knows if there's actually anything at all to render for //a dashboard for a given section, then the UI can deal with it accordingly (i.e. redirect to the first tree) foreach (var section in sectionModels) { var hasDashboards = false; - IEnumerable> dashboardsForSection; - if (dashboards.TryGetValue(section.Alias, out dashboardsForSection)) + if (dashboards.TryGetValue(section.Alias, out var dashboardsForSection)) { if (dashboardsForSection.Any()) hasDashboards = true; diff --git a/src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs b/src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs index e9b3f4dabf..a38a15608d 100644 --- a/src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs +++ b/src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs @@ -13,7 +13,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods { private readonly ILocalizedTextService _textService; - internal EmailNotificationMethod(ILocalizedTextService textService) + public EmailNotificationMethod(ILocalizedTextService textService) { var recipientEmail = Settings["recipientEmail"]?.Value; if (string.IsNullOrWhiteSpace(recipientEmail)) diff --git a/src/Umbraco.Web/Mvc/RenderViewEngine.cs b/src/Umbraco.Web/Mvc/RenderViewEngine.cs index a4899bf24b..6725123a8f 100644 --- a/src/Umbraco.Web/Mvc/RenderViewEngine.cs +++ b/src/Umbraco.Web/Mvc/RenderViewEngine.cs @@ -1,8 +1,8 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Web.Mvc; -using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Web.Models; @@ -27,15 +27,12 @@ namespace Umbraco.Web.Mvc { const string templateFolder = Constants.ViewLocation; - var replaceWithUmbracoFolder = _supplementedViewLocations.ForEach(location => templateFolder + location); - var replacePartialWithUmbracoFolder = _supplementedPartialViewLocations.ForEach(location => templateFolder + location); - // the Render view engine doesn't support Area's so make those blank - ViewLocationFormats = replaceWithUmbracoFolder.ToArray(); - PartialViewLocationFormats = replacePartialWithUmbracoFolder.ToArray(); + ViewLocationFormats = _supplementedViewLocations.Select(x => templateFolder + x).ToArray(); + PartialViewLocationFormats = _supplementedPartialViewLocations.Select(x => templateFolder + x).ToArray(); - AreaPartialViewLocationFormats = new string[] { }; - AreaViewLocationFormats = new string[] { }; + AreaPartialViewLocationFormats = Array.Empty(); + AreaViewLocationFormats = Array.Empty(); EnsureFoldersAndFiles(); } @@ -49,9 +46,10 @@ namespace Umbraco.Web.Mvc // ensure the web.config file is in the ~/Views folder Directory.CreateDirectory(viewFolder); - if (File.Exists(Path.Combine(viewFolder, "web.config")) == false) + var webConfigPath = Path.Combine(viewFolder, "web.config"); + if (File.Exists(webConfigPath) == false) { - using (var writer = File.CreateText(Path.Combine(viewFolder, "web.config"))) + using (var writer = File.CreateText(webConfigPath)) { writer.Write(Strings.WebConfigTemplate); } @@ -92,12 +90,11 @@ namespace Umbraco.Web.Mvc // first check if we're rendering a partial view for the back office, or surface controller, etc... // anything that is not IUmbracoRenderModel as this should only pertain to Umbraco views. - if (isPartial && (umbracoToken is ContentModel == false)) + if (isPartial && !(umbracoToken is ContentModel)) return true; // only find views if we're rendering the umbraco front end return umbracoToken is ContentModel; } - } } diff --git a/src/Umbraco.Web/Mvc/UmbracoViewPageOfTModel.cs b/src/Umbraco.Web/Mvc/UmbracoViewPageOfTModel.cs index 0d9f101882..7532ef7732 100644 --- a/src/Umbraco.Web/Mvc/UmbracoViewPageOfTModel.cs +++ b/src/Umbraco.Web/Mvc/UmbracoViewPageOfTModel.cs @@ -225,8 +225,6 @@ namespace Umbraco.Web.Mvc } base.WriteLiteral(value); - - } public HelperResult RenderSection(string name, Func defaultContents) diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs index 58e57ba247..d9079e53a6 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs @@ -25,7 +25,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters /// /// Initializes a new instance of the class. /// - public NestedContentManyValueConverter(IFacadeAccessor facadeAccessor, IFacadeService facadeService, IPublishedModelFactory publishedModelFactory, ProfilingLogger proflog) + public NestedContentManyValueConverter(IFacadeAccessor facadeAccessor, Lazy facadeService, IPublishedModelFactory publishedModelFactory, ProfilingLogger proflog) : base(facadeAccessor, facadeService, publishedModelFactory) { _proflog = proflog; diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs index cdaada3d99..78f101e9cf 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs @@ -20,7 +20,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters /// /// Initializes a new instance of the class. /// - public NestedContentSingleValueConverter(IFacadeAccessor facadeAccessor, IFacadeService facadeService, IPublishedModelFactory publishedModelFactory, ProfilingLogger proflog) + public NestedContentSingleValueConverter(IFacadeAccessor facadeAccessor, Lazy facadeService, IPublishedModelFactory publishedModelFactory, ProfilingLogger proflog) : base(facadeAccessor, facadeService, publishedModelFactory) { _proflog = proflog; diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs index aa248158c1..b449b13fef 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs @@ -11,15 +11,17 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public abstract class NestedContentValueConverterBase : PropertyValueConverterBase { private readonly IFacadeAccessor _facadeAccessor; - private readonly IFacadeService _facadeService; + private readonly Lazy _facadeService; - protected NestedContentValueConverterBase(IFacadeAccessor facadeAccessor, IFacadeService facadeService, IPublishedModelFactory publishedModelFactory) + protected NestedContentValueConverterBase(IFacadeAccessor facadeAccessor, Lazy facadeService, IPublishedModelFactory publishedModelFactory) { _facadeAccessor = facadeAccessor; _facadeService = facadeService; PublishedModelFactory = publishedModelFactory; } + protected IFacadeService FacadeService => _facadeService.Value; + protected IPublishedModelFactory PublishedModelFactory { get; } public static bool IsNested(PublishedPropertyType publishedProperty) @@ -63,7 +65,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters key = Guid.Empty; // fixme - why does it need a facade service here? - IPublishedElement element = new PublishedElement(publishedContentType, key, propertyValues, preview, _facadeService, referenceCacheLevel); + IPublishedElement element = new PublishedElement(publishedContentType, key, propertyValues, preview, FacadeService, referenceCacheLevel); element = PublishedModelFactory.CreateModel(element); return element; diff --git a/src/Umbraco.Web/PublishedModels/DummyClassSoThatPublishedModelsNamespaceExists.cs b/src/Umbraco.Web/PublishedModels/DummyClassSoThatPublishedModelsNamespaceExists.cs new file mode 100644 index 0000000000..9691cb5a94 --- /dev/null +++ b/src/Umbraco.Web/PublishedModels/DummyClassSoThatPublishedModelsNamespaceExists.cs @@ -0,0 +1,9 @@ +namespace Umbraco.Web.PublishedModels +{ + // this is here so that Umbraco.Web.PublishedModels namespace exists in views + // even if people are not using models at all - because we are referencing it + // when compiling views - hopefully noone will ever create an actual model + // with that name + internal class DummyClassSoThatPublishedModelsNamespaceExists + { } +} diff --git a/src/Umbraco.Web/Trees/ApplicationTreeController.cs b/src/Umbraco.Web/Trees/ApplicationTreeController.cs index b5e5a6cfc0..0ab6a4ec75 100644 --- a/src/Umbraco.Web/Trees/ApplicationTreeController.cs +++ b/src/Umbraco.Web/Trees/ApplicationTreeController.cs @@ -81,7 +81,7 @@ namespace Umbraco.Web.Trees /// private async Task GetRootForMultipleAppTree(ApplicationTree configTree, FormDataCollection queryStrings) { - if (configTree == null) throw new ArgumentNullException("configTree"); + if (configTree == null) throw new ArgumentNullException(nameof(configTree)); var byControllerAttempt = await configTree.TryGetRootNodeFromControllerTree(queryStrings, ControllerContext); if (byControllerAttempt.Success) { @@ -108,7 +108,7 @@ namespace Umbraco.Web.Trees private async Task GetRootForSingleAppTree(ApplicationTree configTree, string id, FormDataCollection queryStrings, string application) { var rootId = Constants.System.Root.ToString(CultureInfo.InvariantCulture); - if (configTree == null) throw new ArgumentNullException("configTree"); + if (configTree == null) throw new ArgumentNullException(nameof(configTree)); var byControllerAttempt = configTree.TryLoadFromControllerTree(id, queryStrings, ControllerContext); if (byControllerAttempt.Success) { @@ -167,9 +167,5 @@ namespace Umbraco.Web.Trees throw new ApplicationException("Could not render a tree for type " + configTree.Alias); } - - } - - } diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index c8f4c9ee34..798a96509f 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -305,6 +305,7 @@ + @@ -1065,7 +1066,6 @@ - @@ -1551,7 +1551,6 @@ - @@ -1666,7 +1665,6 @@ Settings1.Designer.cs - diff --git a/src/Umbraco.Web/WebRuntime.cs b/src/Umbraco.Web/WebRuntime.cs index b2fcb88d49..741f735f38 100644 --- a/src/Umbraco.Web/WebRuntime.cs +++ b/src/Umbraco.Web/WebRuntime.cs @@ -6,7 +6,6 @@ using Umbraco.Core.Logging; using Umbraco.Core.Cache; using Umbraco.Core.Configuration; using Umbraco.Core.Composing; -using Umbraco.Core.Persistence; namespace Umbraco.Web { @@ -46,8 +45,8 @@ namespace Umbraco.Web base.Boot(container); // now (and only now) is the time to switch over to perWebRequest scopes - var smp = container.ScopeManagerProvider as MixedLightInjectScopeManagerProvider; - if (smp == null) throw new Exception("Container.ScopeManagerProvider is not MixedLightInjectScopeManagerProvider."); + if (!(container.ScopeManagerProvider is MixedLightInjectScopeManagerProvider smp)) + throw new Exception("Container.ScopeManagerProvider is not MixedLightInjectScopeManagerProvider."); smp.EnablePerWebRequestScope(); } @@ -57,7 +56,7 @@ namespace Umbraco.Web base.Compose(container); // replace CoreRuntime's IProfiler registration - container.RegisterSingleton(_ => _webProfiler); + container.RegisterSingleton(_ => _webProfiler); // replace CoreRuntime's CacheHelper registration container.RegisterSingleton(_ => new CacheHelper( diff --git a/src/Umbraco.Web/WebRuntimeComponent.cs b/src/Umbraco.Web/WebRuntimeComponent.cs index 7c347d67ae..86c413a2ca 100644 --- a/src/Umbraco.Web/WebRuntimeComponent.cs +++ b/src/Umbraco.Web/WebRuntimeComponent.cs @@ -98,8 +98,8 @@ namespace Umbraco.Web // IoC setup for LightInject for MVC/WebApi // see comments on MixedLightInjectScopeManagerProvider for explainations of what we are doing here - var smp = composition.Container.ScopeManagerProvider as MixedLightInjectScopeManagerProvider; - if (smp == null) throw new Exception("Container.ScopeManagerProvider is not MixedLightInjectScopeManagerProvider."); + if (!(composition.Container.ScopeManagerProvider is MixedLightInjectScopeManagerProvider smp)) + throw new Exception("Container.ScopeManagerProvider is not MixedLightInjectScopeManagerProvider."); composition.Container.EnableMvc(); // does container.EnablePerWebRequestScope() composition.Container.ScopeManagerProvider = smp; // reverts - we will do it last (in WebRuntime) @@ -206,8 +206,7 @@ namespace Umbraco.Web ClientDependency.Core.CompositeFiles.Providers.XmlFileMapper.FileMapVirtualFolder = "~/App_Data/TEMP/ClientDependency"; ClientDependency.Core.CompositeFiles.Providers.BaseCompositeFileProcessingProvider.UrlTypeDefault = ClientDependency.Core.CompositeFiles.Providers.CompositeUrlType.Base64QueryStrings; - var section = ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection; - if (section != null) + if (ConfigurationManager.GetSection("system.web/httpRuntime") is HttpRuntimeSection section) { //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); diff --git a/src/Umbraco.Web/_Legacy/Packager/FileResources/PackageFiles.Designer.cs b/src/Umbraco.Web/_Legacy/Packager/FileResources/PackageFiles.Designer.cs deleted file mode 100644 index 0666ea77f2..0000000000 --- a/src/Umbraco.Web/_Legacy/Packager/FileResources/PackageFiles.Designer.cs +++ /dev/null @@ -1,73 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.cms.businesslogic.Packager.FileResources { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class PackageFiles { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal PackageFiles() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("umbraco.cms.businesslogic.Packager.FileResources.PackageFiles", typeof(PackageFiles).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?> - ///<packages></packages>. - /// - internal static string Packages { - get { - return ResourceManager.GetString("Packages", resourceCulture); - } - } - } -} diff --git a/src/Umbraco.Web/_Legacy/Packager/FileResources/PackageFiles.resx b/src/Umbraco.Web/_Legacy/Packager/FileResources/PackageFiles.resx deleted file mode 100644 index 544e9da936..0000000000 --- a/src/Umbraco.Web/_Legacy/Packager/FileResources/PackageFiles.resx +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - packages.config;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 - - \ No newline at end of file diff --git a/src/Umbraco.Web/_Legacy/Packager/FileResources/Packages.config b/src/Umbraco.Web/_Legacy/Packager/FileResources/Packages.config deleted file mode 100644 index 23363f82ce..0000000000 --- a/src/Umbraco.Web/_Legacy/Packager/FileResources/Packages.config +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/src/Umbraco.Web/_Legacy/Packager/data.cs b/src/Umbraco.Web/_Legacy/Packager/data.cs index 0edb1017c9..3cb1148bb4 100644 --- a/src/Umbraco.Web/_Legacy/Packager/data.cs +++ b/src/Umbraco.Web/_Legacy/Packager/data.cs @@ -18,15 +18,7 @@ namespace umbraco.cms.businesslogic.packager /// public class data { - private static XmlDocument _source; - - public static XmlDocument Source - { - get - { - return _source; - } - } + public static XmlDocument Source { get; private set; } public static void Reload(string dataSource) { @@ -48,15 +40,15 @@ namespace umbraco.cms.businesslogic.packager using (StreamWriter sw = File.CreateText(dataSource)) { - sw.Write(umbraco.cms.businesslogic.Packager.FileResources.PackageFiles.Packages); + sw.Write($@"{Environment.NewLine}{Environment.NewLine}"); sw.Flush(); } } - if (_source == null) + if (Source == null) { - _source = new XmlDocument(); + Source = new XmlDocument(); } //error checking here @@ -76,7 +68,7 @@ namespace umbraco.cms.businesslogic.packager } } - _source.Load(dataSource); + Source.Load(dataSource); } public static XmlNode GetFromId(int Id, string dataSource, bool reload)