From 2ef4b77bd9e665419e9e1757a9da58f0839b33af Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 24 Sep 2013 11:28:32 +0200 Subject: [PATCH 1/2] Fix broken tests --- .../PublishedContent/DynamicDocumentTestsBase.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs b/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs index 4f497a1613..071a638532 100644 --- a/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs +++ b/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs @@ -105,10 +105,10 @@ namespace Umbraco.Tests.PublishedContent var doc = GetDynamicNode(1174); var prop = doc.GetProperty("siteTitle", true); Assert.IsNotNull(prop); - Assert.AreEqual("This is my site", prop.Value); + Assert.AreEqual("This is my site", prop.ObjectValue); prop = doc.GetProperty("_siteTitle"); //test with underscore prefix Assert.IsNotNull(prop); - Assert.AreEqual("This is my site", prop.Value); + Assert.AreEqual("This is my site", prop.ObjectValue); Assert.AreEqual("This is my site", doc._siteTitle); } @@ -127,7 +127,7 @@ namespace Umbraco.Tests.PublishedContent Assert.IsTrue(doc.HasProperty(Constants.Conventions.Content.UrlAlias)); var prop = doc.GetProperty(Constants.Conventions.Content.UrlAlias); Assert.IsNotNull(prop); - Assert.AreEqual("page2/alias, 2ndpagealias", prop.Value); + Assert.AreEqual("page2/alias, 2ndpagealias", prop.ObjectValue); Assert.AreEqual("page2/alias, 2ndpagealias", doc.umbracoUrlAlias); } From 725b938de1310055e13398b2044e0f16a7980520 Mon Sep 17 00:00:00 2001 From: Stephan Date: Wed, 25 Sep 2013 13:16:37 +0200 Subject: [PATCH 2/2] PublishedContent - revert to using property.Value vs .ObjectValue --- src/Umbraco.Core/Dynamics/PropertyResult.cs | 6 +++--- src/Umbraco.Core/Models/IPublishedProperty.cs | 2 +- .../PublishedContent/PublishedContentExtended.cs | 2 +- .../Models/PublishedContent/PublishedPropertyBase.cs | 2 +- src/Umbraco.Tests/CodeFirst/ContentTypeMapper.cs | 6 +++--- .../PublishedContent/DynamicDocumentTestsBase.cs | 6 +++--- .../PublishedContentDataTableTests.cs | 2 +- .../PublishedContent/PublishedContentMoreTests.cs | 6 +++--- .../PublishedContent/PublishedContentTestElements.cs | 4 ++-- src/Umbraco.Web/Models/DynamicPublishedContent.cs | 6 +++--- src/Umbraco.Web/Models/PublishedContentBase.cs | 4 ++-- .../XmlPublishedCache/PublishedMediaCache.cs | 2 +- .../XmlPublishedCache/XmlPublishedProperty.cs | 2 +- src/Umbraco.Web/PublishedContentExtensions.cs | 12 ++++++------ src/Umbraco.Web/PublishedContentPropertyExtension.cs | 2 +- src/Umbraco.Web/umbraco.presentation/library.cs | 6 +++--- src/Umbraco.Web/umbraco.presentation/page.cs | 2 +- .../RazorDynamicNode/PublishedContentExtensions.cs | 2 +- 18 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/Umbraco.Core/Dynamics/PropertyResult.cs b/src/Umbraco.Core/Dynamics/PropertyResult.cs index 0a0bfbc6e0..59d3a0f247 100644 --- a/src/Umbraco.Core/Dynamics/PropertyResult.cs +++ b/src/Umbraco.Core/Dynamics/PropertyResult.cs @@ -34,13 +34,13 @@ namespace Umbraco.Core.Dynamics public string PropertyTypeAlias { get { return _source == null ? _alias : _source.PropertyTypeAlias; } } public object DataValue { get { return _source == null ? _value : _source.DataValue; } } public bool HasValue { get { return _source == null || _source.HasValue; } } - public object ObjectValue { get { return _source == null ? _value : _source.ObjectValue; } } - public object XPathValue { get { return ObjectValue == null ? null : ObjectValue.ToString(); } } + public object Value { get { return _source == null ? _value : _source.Value; } } + public object XPathValue { get { return Value == null ? null : Value.ToString(); } } // implements IHtmlString.ToHtmlString public string ToHtmlString() { - var value = ObjectValue; + var value = Value; return value == null ? string.Empty : value.ToString(); } } diff --git a/src/Umbraco.Core/Models/IPublishedProperty.cs b/src/Umbraco.Core/Models/IPublishedProperty.cs index 45ada63e17..f6afa1f05e 100644 --- a/src/Umbraco.Core/Models/IPublishedProperty.cs +++ b/src/Umbraco.Core/Models/IPublishedProperty.cs @@ -45,7 +45,7 @@ namespace Umbraco.Core.Models /// It can be null, or any type of CLR object. /// It has been fully prepared and processed by the appropriate converter. /// - object ObjectValue { get; } + object Value { get; } /// /// Gets the XPath value of the property. diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentExtended.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentExtended.cs index 37c9ab3203..86ebb83919 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentExtended.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentExtended.cs @@ -132,7 +132,7 @@ namespace Umbraco.Core.Models.PublishedContent if (_properties != null) { var property = _properties.FirstOrDefault(prop => prop.PropertyTypeAlias.InvariantEquals(alias)); - if (property != null) return property.HasValue ? property.ObjectValue : null; + if (property != null) return property.HasValue ? property.Value : null; } return Content[alias]; } diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs index d19a79b149..b841b85212 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs @@ -25,7 +25,7 @@ namespace Umbraco.Core.Models.PublishedContent // these have to be provided by the actual implementation public abstract bool HasValue { get; } public abstract object DataValue { get; } - public abstract object ObjectValue { get; } + public abstract object Value { get; } public abstract object XPathValue { get; } } } diff --git a/src/Umbraco.Tests/CodeFirst/ContentTypeMapper.cs b/src/Umbraco.Tests/CodeFirst/ContentTypeMapper.cs index f09db20db4..80ddb57835 100644 --- a/src/Umbraco.Tests/CodeFirst/ContentTypeMapper.cs +++ b/src/Umbraco.Tests/CodeFirst/ContentTypeMapper.cs @@ -27,12 +27,12 @@ namespace Umbraco.Tests.CodeFirst object value = null; //TODO Proper mapping of types if (propertyInfo.PropertyType == typeof(string)) - value = property.ObjectValue; + value = property.Value; else if (propertyInfo.PropertyType == typeof(DateTime)) - value = DateTime.Parse(property.ObjectValue.ToString()); + value = DateTime.Parse(property.Value.ToString()); else if (propertyInfo.PropertyType == typeof(Boolean)) { - if (String.IsNullOrEmpty(property.ObjectValue.ToString()) || property.ObjectValue == "0") + if (String.IsNullOrEmpty(property.Value.ToString()) || property.Value == "0") { value = false; } diff --git a/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs b/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs index 071a638532..4f497a1613 100644 --- a/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs +++ b/src/Umbraco.Tests/PublishedContent/DynamicDocumentTestsBase.cs @@ -105,10 +105,10 @@ namespace Umbraco.Tests.PublishedContent var doc = GetDynamicNode(1174); var prop = doc.GetProperty("siteTitle", true); Assert.IsNotNull(prop); - Assert.AreEqual("This is my site", prop.ObjectValue); + Assert.AreEqual("This is my site", prop.Value); prop = doc.GetProperty("_siteTitle"); //test with underscore prefix Assert.IsNotNull(prop); - Assert.AreEqual("This is my site", prop.ObjectValue); + Assert.AreEqual("This is my site", prop.Value); Assert.AreEqual("This is my site", doc._siteTitle); } @@ -127,7 +127,7 @@ namespace Umbraco.Tests.PublishedContent Assert.IsTrue(doc.HasProperty(Constants.Conventions.Content.UrlAlias)); var prop = doc.GetProperty(Constants.Conventions.Content.UrlAlias); Assert.IsNotNull(prop); - Assert.AreEqual("page2/alias, 2ndpagealias", prop.ObjectValue); + Assert.AreEqual("page2/alias, 2ndpagealias", prop.Value); Assert.AreEqual("page2/alias, 2ndpagealias", doc.umbracoUrlAlias); } diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs index a641746406..59b75b4e03 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs @@ -215,7 +215,7 @@ namespace Umbraco.Tests.PublishedContent public object this[string propertyAlias] { - get { return GetProperty(propertyAlias).ObjectValue; } + get { return GetProperty(propertyAlias).Value; } } public IEnumerable Children { get; set; } diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs index c51613b8b8..a75ef9e2e6 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs @@ -228,7 +228,7 @@ namespace Umbraco.Tests.PublishedContent { PropertyTypeAlias = "prop1", HasValue = true, - ObjectValue = 1234, + Value = 1234, DataValue = "1234" } } @@ -251,7 +251,7 @@ namespace Umbraco.Tests.PublishedContent { PropertyTypeAlias = "prop1", HasValue = true, - ObjectValue = 1234, + Value = 1234, DataValue = "1234" } } @@ -274,7 +274,7 @@ namespace Umbraco.Tests.PublishedContent { PropertyTypeAlias = "prop1", HasValue = true, - ObjectValue = 1234, + Value = 1234, DataValue = "1234" } } diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs index 9ec15c66d5..e8145326ea 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs @@ -206,7 +206,7 @@ namespace Umbraco.Tests.PublishedContent get { var property = GetProperty(alias); - return property == null || property.HasValue == false ? null : property.ObjectValue; + return property == null || property.HasValue == false ? null : property.Value; } } @@ -222,7 +222,7 @@ namespace Umbraco.Tests.PublishedContent public string PropertyTypeAlias { get; set; } public object DataValue { get; set; } - public object ObjectValue { get; set; } + public object Value { get; set; } public bool HasValue { get; set; } public object XPathValue { get; set; } } diff --git a/src/Umbraco.Web/Models/DynamicPublishedContent.cs b/src/Umbraco.Web/Models/DynamicPublishedContent.cs index 38f36de240..6c38383490 100644 --- a/src/Umbraco.Web/Models/DynamicPublishedContent.cs +++ b/src/Umbraco.Web/Models/DynamicPublishedContent.cs @@ -177,7 +177,7 @@ namespace Umbraco.Web.Models { var reflectedProperty = GetReflectedProperty(binder.Name); var result = reflectedProperty != null - ? reflectedProperty.ObjectValue + ? reflectedProperty.Value : null; return Attempt.If(result != null, result); @@ -722,8 +722,8 @@ namespace Umbraco.Web.Models public string GetPropertyValue(string alias, bool recursive) { var property = GetProperty(alias, recursive); - if (property == null || property.ObjectValue == null) return null; - return property.ObjectValue.ToString(); + if (property == null || property.Value == null) return null; + return property.Value.ToString(); } #endif diff --git a/src/Umbraco.Web/Models/PublishedContentBase.cs b/src/Umbraco.Web/Models/PublishedContentBase.cs index c0a58ffbdf..3db343c8db 100644 --- a/src/Umbraco.Web/Models/PublishedContentBase.cs +++ b/src/Umbraco.Web/Models/PublishedContentBase.cs @@ -47,7 +47,7 @@ namespace Umbraco.Web.Models var prop = GetProperty(Constants.Conventions.Media.File); if (prop == null) throw new NotSupportedException("Cannot resolve a Url for a media item when there is no 'umbracoFile' property defined."); - _url = prop.ObjectValue.ToString(); + _url = prop.Value.ToString(); break; default: throw new ArgumentOutOfRangeException(); @@ -144,7 +144,7 @@ namespace Umbraco.Web.Models { // no cache here: GetProperty should be fast, and .Value cache should be managed by the property. var property = GetProperty(alias); - return property == null ? null : property.ObjectValue; + return property == null ? null : property.Value; } } diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs index 1d7dd6ab36..214b287b19 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs @@ -331,7 +331,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache { // so in dd.Properties, there is an IPublishedProperty with property type alias "__NodeTypeAlias" and // that special property would contain the node type alias, which we use to get "aliases & names". That - // special property is going to be a PropertyResult (with ObjectValue == DataValue) and we + // special property is going to be a PropertyResult (with Value == DataValue) and we // want its value in the most simple way = it is OK to use DataValue here. var aliasesAndNames = ContentType.GetAliasesAndNames(dd.Properties.First(x => x.PropertyTypeAlias.InvariantEquals(UmbracoContentIndexer.NodeTypeAliasFieldName)).DataValue.ToString()); if (aliasesAndNames != null) diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedProperty.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedProperty.cs index a75ea7c4a3..cf260a8d01 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedProperty.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedProperty.cs @@ -34,7 +34,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache get { return _xmlValue.Trim().Length > 0; } } - public override object ObjectValue { get { return _objectValue.Value; } } + public override object Value { get { return _objectValue.Value; } } public override object XPathValue { get { return _xpathValue.Value; } } public XmlPublishedProperty(PublishedPropertyType propertyType, bool isPreviewing, XmlNode propertyXmlData) diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index 65038f01c6..47c03697f3 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -206,7 +206,7 @@ namespace Umbraco.Web public static object GetPropertyValue(this IPublishedContent content, string alias) { var property = content.GetProperty(alias); - return property == null ? null : property.ObjectValue; + return property == null ? null : property.Value; } /// @@ -225,7 +225,7 @@ namespace Umbraco.Web public static object GetPropertyValue(this IPublishedContent content, string alias, string defaultValue) { var property = content.GetProperty(alias); - return property == null || property.HasValue == false ? defaultValue : property.ObjectValue; + return property == null || property.HasValue == false ? defaultValue : property.Value; } /// @@ -244,7 +244,7 @@ namespace Umbraco.Web public static object GetPropertyValue(this IPublishedContent content, string alias, object defaultValue) { var property = content.GetProperty(alias); - return property == null || property.HasValue == false ? defaultValue : property.ObjectValue; + return property == null || property.HasValue == false ? defaultValue : property.Value; } /// @@ -264,7 +264,7 @@ namespace Umbraco.Web public static object GetPropertyValue(this IPublishedContent content, string alias, bool recurse) { var property = content.GetProperty(alias, recurse); - return property == null ? null : property.ObjectValue; + return property == null ? null : property.Value; } /// @@ -285,7 +285,7 @@ namespace Umbraco.Web public static object GetPropertyValue(this IPublishedContent content, string alias, bool recurse, object defaultValue) { var property = content.GetProperty(alias, recurse); - return property == null || property.HasValue == false ? defaultValue : property.ObjectValue; + return property == null || property.HasValue == false ? defaultValue : property.Value; } #endregion @@ -1622,7 +1622,7 @@ namespace Umbraco.Web foreach (var p in from IPublishedProperty p in n.Properties where p.DataValue != null select p) { // probably want the "object value" of the property here... - userVals[p.PropertyTypeAlias] = p.ObjectValue; + userVals[p.PropertyTypeAlias] = p.Value; } //add the row data Core.DataTableExtensions.AddRowData(tableData, standardVals, userVals); diff --git a/src/Umbraco.Web/PublishedContentPropertyExtension.cs b/src/Umbraco.Web/PublishedContentPropertyExtension.cs index efcf4d6fb6..ee4dd83e57 100644 --- a/src/Umbraco.Web/PublishedContentPropertyExtension.cs +++ b/src/Umbraco.Web/PublishedContentPropertyExtension.cs @@ -28,7 +28,7 @@ namespace Umbraco.Web // else we use .Value so we give the converter a chance to handle the default value differently // eg for IEnumerable it may return Enumerable.Empty instead of null - var value = property.ObjectValue; + var value = property.Value; // if value is null (strange but why not) it still is OK to call TryConvertTo // because it's an extension method (hence no NullRef) which will return a diff --git a/src/Umbraco.Web/umbraco.presentation/library.cs b/src/Umbraco.Web/umbraco.presentation/library.cs index ce69560255..07c9aa4330 100644 --- a/src/Umbraco.Web/umbraco.presentation/library.cs +++ b/src/Umbraco.Web/umbraco.presentation/library.cs @@ -367,11 +367,11 @@ namespace umbraco // where prop.Value is parsed for internal links + resolve urls - but not for macros // comments say "fixing U4-917 and U4-821" which are not related // if we return DataValue.ToString() we're back to the original situation - // if we return ObjectValue.ToString() we'll have macros parsed and that's nice + // if we return Value.ToString() we'll have macros parsed and that's nice // - // so, use ObjectValue.ToString() here. + // so, use Value.ToString() here. var prop = doc.GetProperty(alias); - return prop == null ? string.Empty : prop.ObjectValue.ToString(); + return prop == null ? string.Empty : prop.Value.ToString(); } /// diff --git a/src/Umbraco.Web/umbraco.presentation/page.cs b/src/Umbraco.Web/umbraco.presentation/page.cs index b63317c577..36b8abfdb7 100644 --- a/src/Umbraco.Web/umbraco.presentation/page.cs +++ b/src/Umbraco.Web/umbraco.presentation/page.cs @@ -275,7 +275,7 @@ namespace umbraco { if (!_elements.ContainsKey(p.PropertyTypeAlias)) { - _elements[p.PropertyTypeAlias] = p.ObjectValue; + _elements[p.PropertyTypeAlias] = p.Value; } } } diff --git a/src/umbraco.MacroEngines/RazorDynamicNode/PublishedContentExtensions.cs b/src/umbraco.MacroEngines/RazorDynamicNode/PublishedContentExtensions.cs index 05f419d2e8..cf5180d5e1 100644 --- a/src/umbraco.MacroEngines/RazorDynamicNode/PublishedContentExtensions.cs +++ b/src/umbraco.MacroEngines/RazorDynamicNode/PublishedContentExtensions.cs @@ -20,7 +20,7 @@ namespace umbraco.MacroEngines.Library { internal static IProperty ConvertToNodeProperty(this IPublishedProperty prop) { - return new PropertyResult(prop.PropertyTypeAlias, prop.ObjectValue.ToString()); + return new PropertyResult(prop.PropertyTypeAlias, prop.Value.ToString()); } internal static INode ConvertToNode(this IPublishedContent doc)