diff --git a/src/Umbraco.Core/CacheHelper.cs b/src/Umbraco.Core/CacheHelper.cs index 0de92e1259..8bb80670d8 100644 --- a/src/Umbraco.Core/CacheHelper.cs +++ b/src/Umbraco.Core/CacheHelper.cs @@ -74,14 +74,6 @@ namespace Umbraco.Core { } - internal void ClearStaticCacheObjectTypes(Func predicate) - { - if (_enableCache) - _staticCache.ClearCacheObjectTypes(predicate); - else - _nullStaticCache.ClearCacheObjectTypes(predicate); - } - /// /// Private ctor used for creating a disabled cache helper /// diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs index 773da45ccf..8f6c33bec2 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs @@ -102,7 +102,7 @@ namespace Umbraco.Core.Models.PublishedContent Logging.LogHelper.Debug("Clear all."); // ok and faster to do it by types, assuming noone else caches PublishedContentType instances //ApplicationContext.Current.ApplicationCache.ClearStaticCacheByKeySearch("PublishedContentType_"); - ApplicationContext.Current.ApplicationCache.ClearStaticCacheObjectTypes(); + ApplicationContext.Current.ApplicationCache.StaticCache.ClearCacheObjectTypes(); } internal static void ClearContentType(int id) @@ -110,7 +110,7 @@ namespace Umbraco.Core.Models.PublishedContent Logging.LogHelper.Debug("Clear content type w/id {0}.", () => id); // requires a predicate because the key does not contain the ID // faster than key strings comparisons anyway - ApplicationContext.Current.ApplicationCache.ClearStaticCacheObjectTypes( + ApplicationContext.Current.ApplicationCache.StaticCache.ClearCacheObjectTypes( (key, value) => value.Id == id); } @@ -121,7 +121,7 @@ namespace Umbraco.Core.Models.PublishedContent // properties ie both its own properties and those that were inherited (it's based upon an // IContentTypeComposition) and so every PublishedContentType having a property based upon // the cleared data type, be it local or inherited, will be cleared. - ApplicationContext.Current.ApplicationCache.ClearStaticCacheObjectTypes( + ApplicationContext.Current.ApplicationCache.StaticCache.ClearCacheObjectTypes( // fixme NOT! (key, value) => value.PropertyTypes.Any(x => x.DataTypeId == id)); } @@ -130,7 +130,7 @@ namespace Umbraco.Core.Models.PublishedContent var key = string.Format("PublishedContentType_{0}_{1}", itemType == PublishedItemType.Content ? "content" : "media", alias.ToLowerInvariant()); - var type = ApplicationContext.Current.ApplicationCache.GetStaticCacheItem(key, + var type = ApplicationContext.Current.ApplicationCache.StaticCache.GetCacheItem(key, () => CreatePublishedContentType(itemType, alias)); return type; @@ -157,7 +157,7 @@ namespace Umbraco.Core.Models.PublishedContent { // see note above //ClearAll(); - ApplicationContext.Current.ApplicationCache.ClearStaticCacheByKeySearch("PublishedContentType_"); + ApplicationContext.Current.ApplicationCache.StaticCache.ClearCacheByKeySearch("PublishedContentType_"); _getPublishedContentTypeCallBack = value; } diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs index 554b6bcfa8..a95ba2eb85 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs @@ -24,22 +24,19 @@ namespace Umbraco.Core.Models.PublishedContent PropertyTypeAlias = propertyType.Alias; DataTypeId = propertyType.DataTypeDefinitionId; - PropertyEditorGuid = propertyType.DataTypeId; - //PropertyEditorAlias = propertyType.PropertyEditorAlias; + PropertyEditorAlias = propertyType.PropertyEditorAlias; InitializeConverters(); } // for unit tests - internal PublishedPropertyType(string propertyTypeAlias, int dataTypeDefinitionId, Guid propertyEditorGuid) - //internal PublishedPropertyType(string propertyTypeAlias, int dataTypeDefinitionId, Alias propertyEditorAlias) + internal PublishedPropertyType(string propertyTypeAlias, int dataTypeDefinitionId, string propertyEditorAlias) { // ContentType to be set by PublishedContentType when creating it PropertyTypeAlias = propertyTypeAlias; DataTypeId = dataTypeDefinitionId; - PropertyEditorGuid = propertyEditorGuid; - //PropertyEditorAlias = PropertyEditorAlias; + PropertyEditorAlias = PropertyEditorAlias; InitializeConverters(); } @@ -62,15 +59,10 @@ namespace Umbraco.Core.Models.PublishedContent /// public int DataTypeId { get; private set; } - /// - /// Gets or sets the guid uniquely identifying the property editor for the property type. - /// - public Guid PropertyEditorGuid { get; private set; } - /// /// Gets or sets the alias uniquely identifying the property editor for the property type. /// - //public string PropertyEditorAlias { get; private set; } + public string PropertyEditorAlias { get; private set; } #endregion @@ -211,9 +203,10 @@ namespace Umbraco.Core.Models.PublishedContent IEnumerable GetCompatConverters() { - return PropertyEditorValueConvertersResolver.HasCurrent + var propertyEditorGuid = LegacyPropertyEditorIdToAliasConverter.GetLegacyIdFromAlias(PropertyEditorAlias); + return PropertyEditorValueConvertersResolver.HasCurrent && propertyEditorGuid.HasValue ? PropertyEditorValueConvertersResolver.Current.Converters - .Where(x => x.IsConverterFor(PropertyEditorGuid, ContentType.Alias, PropertyTypeAlias)) + .Where(x => x.IsConverterFor(propertyEditorGuid.Value, ContentType.Alias, PropertyTypeAlias)) .Select(x => new CompatConverter(x)) : Enumerable.Empty(); } diff --git a/src/Umbraco.Core/Models/PublishedPropertyDefinition.cs b/src/Umbraco.Core/Models/PublishedPropertyDefinition.cs deleted file mode 100644 index 11536aaca7..0000000000 --- a/src/Umbraco.Core/Models/PublishedPropertyDefinition.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Umbraco.Core.Models -{ - /// - /// The definition of a published property - /// - public class PublishedPropertyDefinition - { - public PublishedPropertyDefinition(string propertyTypeAlias, string documentTypeAlias, string propertyEditorAlias) - { - //PropertyId = propertyId; - DocumentTypeAlias = documentTypeAlias; - PropertyTypeAlias = propertyTypeAlias; - PropertyEditorAlias = propertyEditorAlias; - //ItemType = itemType; - } - - //public int PropertyId { get; private set; } - public string DocumentTypeAlias { get; private set; } - public string PropertyTypeAlias { get; private set; } - public string PropertyEditorAlias { get; private set; } - //public PublishedItemType ItemType { get; private set; } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/PluginManager.cs b/src/Umbraco.Core/PluginManager.cs index e24573e4d4..abe822fc44 100644 --- a/src/Umbraco.Core/PluginManager.cs +++ b/src/Umbraco.Core/PluginManager.cs @@ -488,7 +488,7 @@ namespace Umbraco.Core /// internal IEnumerable ResolvePropertyValueConverters() { - return ResolveTypes(); + return ResolveTypes(); } /// diff --git a/src/Umbraco.Core/PropertyEditors/DatePickerPropertyValueConverter.cs b/src/Umbraco.Core/PropertyEditors/DatePickerPropertyValueConverter.cs deleted file mode 100644 index a6692140f9..0000000000 --- a/src/Umbraco.Core/PropertyEditors/DatePickerPropertyValueConverter.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Linq; -using Umbraco.Core.Models; - -namespace Umbraco.Core.PropertyEditors -{ - internal class DatePickerPropertyValueConverter : PropertyValueConverter - { - public override string AssociatedPropertyEditorAlias - { - get { return Constants.PropertyEditors.DateAlias; } - } - - /// - /// return a DateTime object even if the value is a string - /// - /// - /// - /// - /// - public override Attempt ConvertSourceToObject(object valueToConvert, PublishedPropertyDefinition propertyDefinition, bool isPreviewing) - { - return valueToConvert.TryConvertTo(typeof(DateTime)); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/DateTimePickerPropertyValueConverter.cs b/src/Umbraco.Core/PropertyEditors/DateTimePickerPropertyValueConverter.cs deleted file mode 100644 index a22e984092..0000000000 --- a/src/Umbraco.Core/PropertyEditors/DateTimePickerPropertyValueConverter.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using Umbraco.Core.Models; - -namespace Umbraco.Core.PropertyEditors -{ - internal class DateTimePickerPropertyValueConverter : PropertyValueConverter - { - public override string AssociatedPropertyEditorAlias - { - get { return Constants.PropertyEditors.DateTimeAlias; } - } - - /// - /// return a DateTime object even if the value is a string - /// - /// - /// - /// - /// - public override Attempt ConvertSourceToObject(object valueToConvert, PublishedPropertyDefinition propertyDefinition, bool isPreviewing) - { - return valueToConvert.TryConvertTo(typeof(DateTime)); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/PropertyValueConverter.cs b/src/Umbraco.Core/PropertyEditors/PropertyValueConverter.cs index a83a87fb53..648fbeeb64 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyValueConverter.cs @@ -1,17 +1,18 @@ using Umbraco.Core.Models; -namespace Umbraco.Core.PropertyEditors -{ - /// - /// Used to convert property values from various sources to various destination formats for use with caching - /// - public abstract class PropertyValueConverter - { - /// - /// Returns the alias of the PropertyEditor that this converter is for - /// - public abstract string AssociatedPropertyEditorAlias { get; } +// fixme - delete file +//namespace Umbraco.Core.PropertyEditors +//{ +// /// +// /// Used to convert property values from various sources to various destination formats for use with caching +// /// +// public abstract class PropertyValueConverter +// { +// /// +// /// Returns the alias of the PropertyEditor that this converter is for +// /// +// public abstract string AssociatedPropertyEditorAlias { get; } - public abstract Attempt ConvertSourceToObject(object valueToConvert, PublishedPropertyDefinition propertyDefinition, bool isPreviewing); - } -} \ No newline at end of file +// public abstract Attempt ConvertSourceToObject(object valueToConvert, PublishedPropertyDefinition propertyDefinition, bool isPreviewing); +// } +//} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/TinyMcePropertyValueConverter.cs b/src/Umbraco.Core/PropertyEditors/TinyMcePropertyValueConverter.cs deleted file mode 100644 index 9846ffb4da..0000000000 --- a/src/Umbraco.Core/PropertyEditors/TinyMcePropertyValueConverter.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Web; -using Umbraco.Core.Models; - -namespace Umbraco.Core.PropertyEditors -{ - /// - /// Value converter for the RTE so that it always returns IHtmlString so that Html.Raw doesn't have to be used. - /// - internal class TinyMcePropertyValueConverter : PropertyValueConverter - { - public override string AssociatedPropertyEditorAlias - { - get { return Constants.PropertyEditors.TinyMCEv3Alias; } - } - - public override Attempt ConvertSourceToObject(object valueToConvert, PublishedPropertyDefinition propertyDefinition, bool isPreviewing) - { - return new Attempt(true, new HtmlString(valueToConvert.ToString())); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs index bd7793aa0d..c74e1c3313 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs @@ -10,15 +10,15 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters [PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)] public class DatePickerValueConverter : PropertyValueConverterBase { - private static readonly Guid[] DataTypeGuids = new[] - { - Guid.Parse(Constants.PropertyEditors.DateTime), - Guid.Parse(Constants.PropertyEditors.Date) - }; + private static readonly string[] PropertyEditorAliases = + { + Constants.PropertyEditors.DateTimeAlias, + Constants.PropertyEditors.DateAlias + }; public override bool IsConverter(PublishedPropertyType propertyType) { - return DataTypeGuids.Contains(propertyType.PropertyEditorGuid); + return PropertyEditorAliases.Contains(propertyType.PropertyEditorAlias); } public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview) diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs index c7112e51d3..7b02a83176 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs @@ -14,7 +14,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters { public override bool IsConverter(PublishedPropertyType propertyType) { - return Guid.Parse(Constants.PropertyEditors.TinyMCEv3).Equals(propertyType.PropertyEditorGuid); + return propertyType.PropertyEditorAlias == Constants.PropertyEditors.TinyMCEv3Alias; } public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview) diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs index b2f7cead56..191e5ca9db 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs @@ -9,7 +9,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters { public override bool IsConverter(PublishedPropertyType propertyType) { - return Guid.Parse(Constants.PropertyEditors.TrueFalse).Equals(propertyType.PropertyEditorGuid); + return propertyType.PropertyEditorAlias == Constants.PropertyEditors.TrueFalseAlias; } public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview) diff --git a/src/Umbraco.Core/PropertyEditors/YesNoPropertyValueConverter.cs b/src/Umbraco.Core/PropertyEditors/YesNoPropertyValueConverter.cs deleted file mode 100644 index 0d6fc4b979..0000000000 --- a/src/Umbraco.Core/PropertyEditors/YesNoPropertyValueConverter.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using Umbraco.Core.Models; - -namespace Umbraco.Core.PropertyEditors -{ - internal class YesNoPropertyValueConverter : PropertyValueConverter - { - public override string AssociatedPropertyEditorAlias - { - get { return Constants.PropertyEditors.TrueFalseAlias; } - } - - /// - /// Convert from string boolean or 0 or 1 to real boolean - /// - /// - /// - /// - /// - public override Attempt ConvertSourceToObject(object valueToConvert, PublishedPropertyDefinition propertyDefinition, bool isPreviewing) - { - return valueToConvert.TryConvertTo(typeof(bool)); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 80e7d9d717..590fb7b1af 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -308,7 +308,6 @@ - @@ -358,7 +357,6 @@ - @@ -733,7 +731,6 @@ - diff --git a/src/Umbraco.Tests/CodeFirst/StronglyTypedMapperTest.cs b/src/Umbraco.Tests/CodeFirst/StronglyTypedMapperTest.cs index 79cfad7cbb..bd95871063 100644 --- a/src/Umbraco.Tests/CodeFirst/StronglyTypedMapperTest.cs +++ b/src/Umbraco.Tests/CodeFirst/StronglyTypedMapperTest.cs @@ -74,12 +74,12 @@ namespace Umbraco.Tests.CodeFirst var propertyTypes = new[] { // AutoPublishedContentType will auto-generate other properties - new PublishedPropertyType("siteDescription", 0, Guid.Empty), - new PublishedPropertyType("siteName", 0, Guid.Empty), - new PublishedPropertyType("articleContent", 0, Guid.Empty), - new PublishedPropertyType("articleAuthor", 0, Guid.Empty), - new PublishedPropertyType("articleDate", 0, Guid.Empty), - new PublishedPropertyType("pageTitle", 0, Guid.Empty), + new PublishedPropertyType("siteDescription", 0, "?"), + new PublishedPropertyType("siteName", 0, "?"), + new PublishedPropertyType("articleContent", 0, "?"), + new PublishedPropertyType("articleAuthor", 0, "?"), + new PublishedPropertyType("articleDate", 0, "?"), + new PublishedPropertyType("pageTitle", 0, "?"), }; var type = new AutoPublishedContentType(0, "anything", propertyTypes); PublishedContentType.GetPublishedContentTypeCallback = (alias) => type; diff --git a/src/Umbraco.Tests/LibraryTests.cs b/src/Umbraco.Tests/LibraryTests.cs index c724ff0a29..2844ff6853 100644 --- a/src/Umbraco.Tests/LibraryTests.cs +++ b/src/Umbraco.Tests/LibraryTests.cs @@ -39,7 +39,7 @@ namespace Umbraco.Tests var propertyTypes = new[] { // AutoPublishedContentType will auto-generate other properties - new PublishedPropertyType("content", 0, Guid.Empty), + new PublishedPropertyType("content", 0, "?"), }; var type = new AutoPublishedContentType(0, "anything", propertyTypes); PublishedContentType.GetPublishedContentTypeCallback = (alias) => type; diff --git a/src/Umbraco.Tests/PublishedCache/PublishedContentCacheTests.cs b/src/Umbraco.Tests/PublishedCache/PublishedContentCacheTests.cs index ac0465eea6..20f2604c02 100644 --- a/src/Umbraco.Tests/PublishedCache/PublishedContentCacheTests.cs +++ b/src/Umbraco.Tests/PublishedCache/PublishedContentCacheTests.cs @@ -114,12 +114,6 @@ namespace Umbraco.Tests.PublishedCache base.FreezeResolution(); } - [TearDown] - public void TearDown() - { - UmbracoSettings.Reset(); - } - [Test] public void Has_Content_LegacySchema() { diff --git a/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs b/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs index 65f240264a..7c0ca0eaab 100644 --- a/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs +++ b/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs @@ -17,15 +17,6 @@ namespace Umbraco.Tests.PublishedContent [TestFixture] public abstract class DynamicDocumentTestsBase : PublishedContentTestBase { - - public override void Initialize() - { - base.Initialize(); - - var scriptingMock = Mock.Get(UmbracoSettings.Scripting); - scriptingMock.Setup(x => x.DataTypeModelStaticMappings).Returns(new List()); - } - protected override DatabaseBehavior DatabaseTestBehavior { get { return DatabaseBehavior.NoDatabasePerFixture; } @@ -38,6 +29,9 @@ namespace Umbraco.Tests.PublishedContent base.Initialize(); + var scriptingMock = Mock.Get(UmbracoSettings.Scripting); + scriptingMock.Setup(x => x.DataTypeModelStaticMappings).Returns(new List()); + // need to specify a custom callback for unit tests // AutoPublishedContentTypes generates properties automatically // when they are requested, but we must declare those that we @@ -46,14 +40,14 @@ namespace Umbraco.Tests.PublishedContent var propertyTypes = new[] { // AutoPublishedContentType will auto-generate other properties - new PublishedPropertyType("umbracoNaviHide", 0, Guid.Empty), - new PublishedPropertyType("selectedNodes", 0, Guid.Empty), - new PublishedPropertyType("umbracoUrlAlias", 0, Guid.Empty), - new PublishedPropertyType("content", 0, Guid.Parse(Constants.PropertyEditors.TinyMCEv3)), - new PublishedPropertyType("testRecursive", 0, Guid.Empty), - new PublishedPropertyType("siteTitle", 0, Guid.Empty), - new PublishedPropertyType("creatorName", 0, Guid.Empty), - new PublishedPropertyType("blah", 0, Guid.Empty), // ugly error when that one is missing... + new PublishedPropertyType("umbracoNaviHide", 0, "?"), + new PublishedPropertyType("selectedNodes", 0, "?"), + new PublishedPropertyType("umbracoUrlAlias", 0, "?"), + new PublishedPropertyType("content", 0, Constants.PropertyEditors.TinyMCEv3Alias), + new PublishedPropertyType("testRecursive", 0, "?"), + new PublishedPropertyType("siteTitle", 0, "?"), + new PublishedPropertyType("creatorName", 0, "?"), + new PublishedPropertyType("blah", 0, "?"), // ugly error when that one is missing... }; var type = new AutoPublishedContentType(0, "anything", propertyTypes); PublishedContentType.GetPublishedContentTypeCallback = (alias) => type; diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs index c51613b8b8..a6a9c63797 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Collections.ObjectModel; +using System.Web.Routing; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Models; @@ -9,21 +10,29 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Web; using Umbraco.Tests.TestHelpers; using umbraco.BusinessLogic; +using Umbraco.Web.PublishedCache.XmlPublishedCache; +using Umbraco.Web.Security; namespace Umbraco.Tests.PublishedContent { [TestFixture] - public class PublishedContentMoreTests + public class PublishedContentMoreTests : PublishedContentTestBase { + protected override DatabaseBehavior DatabaseTestBehavior + { + get { return DatabaseBehavior.NoDatabasePerFixture; } + } + // read http://stackoverflow.com/questions/7713326/extension-method-that-works-on-ienumerablet-and-iqueryablet // and http://msmvps.com/blogs/jon_skeet/archive/2010/10/28/overloading-and-generic-constraints.aspx // and http://blogs.msdn.com/b/ericlippert/archive/2009/12/10/constraints-are-not-part-of-the-signature.aspx private PluginManager _pluginManager; - [SetUp] - public void Setup() + public override void Initialize() { + base.Initialize(); + // this is so the model factory looks into the test assembly _pluginManager = PluginManager.Current; PluginManager.Current = new PluginManager(false) @@ -38,20 +47,36 @@ namespace Umbraco.Tests.PublishedContent new PublishedContentModelFactoryResolver(new PublishedContentModelFactoryImpl()); Resolution.Freeze(); + //var caches = CreatePublishedContent(); + + //var factory = new FakeHttpContextFactory("http://umbraco.local/"); + //StateHelper.HttpContext = factory.HttpContext; + //var context = new UmbracoContext( + // factory.HttpContext, + // ApplicationContext.Current, + // caches); + //UmbracoContext.Current = context; + + InitializeUmbracoContext(); + } + + private void InitializeUmbracoContext() + { + RouteData routeData = null; + var caches = CreatePublishedContent(); - ApplicationContext.Current = new ApplicationContext(false) { IsReady = true }; - var factory = new FakeHttpContextFactory("http://umbraco.local/"); - StateHelper.HttpContext = factory.HttpContext; - var context = new UmbracoContext( - factory.HttpContext, - ApplicationContext.Current, - caches); - UmbracoContext.Current = context; + var httpContext = GetHttpContextFactory("http://umbraco.local/", routeData).HttpContext; + var ctx = new UmbracoContext( + httpContext, + ApplicationContext, + caches, + new WebSecurity(httpContext, ApplicationContext)); + + UmbracoContext.Current = ctx; } - [TearDown] - public void TearDown() + public override void TearDown() { PluginManager.Current = _pluginManager; ApplicationContext.Current.DisposeIfDisposable(); @@ -204,7 +229,7 @@ namespace Umbraco.Tests.PublishedContent var props = new[] { - new PublishedPropertyType("prop1", 1, System.Guid.Empty), + new PublishedPropertyType("prop1", 1, "?"), }; var contentType1 = new PublishedContentType(1, "ContentType1", props); diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs index a5779cd988..d83ce1c5dc 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs @@ -27,7 +27,7 @@ namespace Umbraco.Tests.PublishedContent var propertyTypes = new[] { // AutoPublishedContentType will auto-generate other properties - new PublishedPropertyType("content", 0, Guid.Parse(Constants.PropertyEditors.TinyMCEv3)), + new PublishedPropertyType("content", 0, Constants.PropertyEditors.TinyMCEv3Alias), }; var type = new AutoPublishedContentType(0, "anything", propertyTypes); PublishedContentType.GetPublishedContentTypeCallback = (alias) => type; diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs index 9ec15c66d5..70401f5201 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs @@ -286,7 +286,7 @@ namespace Umbraco.Tests.PublishedContent class AutoPublishedContentType : PublishedContentType { - private static readonly PublishedPropertyType Default = new PublishedPropertyType("*", 0, Guid.Empty); + private static readonly PublishedPropertyType Default = new PublishedPropertyType("*", 0, "?"); public AutoPublishedContentType(int id, string alias, IEnumerable propertyTypes) : base(id, alias, propertyTypes) diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs index ada63f7a80..8459baa17e 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs @@ -40,8 +40,6 @@ namespace Umbraco.Tests.PublishedContent .Union(new[] { typeof(PublishedContentTests).Assembly }) }; - ApplicationContext.Current = new ApplicationContext(false) { IsReady = true }; - // need to specify a custom callback for unit tests // AutoPublishedContentTypes generates properties automatically // when they are requested, but we must declare those that we @@ -50,11 +48,11 @@ namespace Umbraco.Tests.PublishedContent var propertyTypes = new[] { // AutoPublishedContentType will auto-generate other properties - new PublishedPropertyType("umbracoNaviHide", 0, Guid.Parse(Constants.PropertyEditors.TrueFalse)), - new PublishedPropertyType("selectedNodes", 0, Guid.Empty), - new PublishedPropertyType("umbracoUrlAlias", 0, Guid.Empty), - new PublishedPropertyType("content", 0, Guid.Parse(Constants.PropertyEditors.TinyMCEv3)), - new PublishedPropertyType("testRecursive", 0, Guid.Empty), + new PublishedPropertyType("umbracoNaviHide", 0, Constants.PropertyEditors.TrueFalseAlias), + new PublishedPropertyType("selectedNodes", 0, "?"), + new PublishedPropertyType("umbracoUrlAlias", 0, "?"), + new PublishedPropertyType("content", 0, Constants.PropertyEditors.TinyMCEv3Alias), + new PublishedPropertyType("testRecursive", 0, "?"), }; var type = new AutoPublishedContentType(0, "anything", propertyTypes); PublishedContentType.GetPublishedContentTypeCallback = (alias) => type; diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs index 5bcca93da5..8e0c66cf2b 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs @@ -374,7 +374,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache if (_xmlNode.Attributes.GetNamedItem("writerID") != null) _writerId = int.Parse(_xmlNode.Attributes.GetNamedItem("writerID").Value); - if (UmbracoSettings.UseLegacyXmlSchema) + if (UmbracoConfiguration.Current.UmbracoSettings.Content.UseLegacyXmlSchema) { if (_xmlNode.Attributes.GetNamedItem("nodeTypeAlias") != null) _docTypeAlias = _xmlNode.Attributes.GetNamedItem("nodeTypeAlias").Value; @@ -401,7 +401,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache } // load data - var dataXPath = UmbracoSettings.UseLegacyXmlSchema ? "data" : "* [not(@isDoc)]"; + var dataXPath = UmbracoConfiguration.Current.UmbracoSettings.Content.UseLegacyXmlSchema ? "data" : "* [not(@isDoc)]"; var nodes = _xmlNode.SelectNodes(dataXPath); _contentType = PublishedContentType.Get(PublishedItemType.Content, _docTypeAlias); @@ -410,7 +410,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache if (nodes != null) foreach (XmlNode n in nodes) { - var alias = UmbracoSettings.UseLegacyXmlSchema + var alias = UmbracoConfiguration.Current.UmbracoSettings.Content.UseLegacyXmlSchema ? n.Attributes.GetNamedItem("alias").Value : n.Name; propertyNodes[alias.ToLowerInvariant()] = n; @@ -433,7 +433,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache if (_xmlNode == null) return; // load children - var childXPath = UmbracoSettings.UseLegacyXmlSchema ? "node" : "* [@isDoc]"; + var childXPath = UmbracoConfiguration.Current.UmbracoSettings.Content.UseLegacyXmlSchema ? "node" : "* [@isDoc]"; var nav = _xmlNode.CreateNavigator(); var expr = nav.Compile(childXPath); expr.AddSort("@sortOrder", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Number); diff --git a/src/Umbraco.Web/umbraco.presentation/macro.cs b/src/Umbraco.Web/umbraco.presentation/macro.cs index a029d61474..620ff7ff62 100644 --- a/src/Umbraco.Web/umbraco.presentation/macro.cs +++ b/src/Umbraco.Web/umbraco.presentation/macro.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Net; using System.Net.Security;