PublishedContent - the big refactoring

This commit is contained in:
Stephan
2013-09-05 17:47:13 +02:00
parent 912716f889
commit 0415a31d0e
115 changed files with 6366 additions and 6233 deletions

View File

@@ -146,7 +146,7 @@ namespace umbraco.MacroEngines
}
if (result != null)
{
return new PropertyResult(alias, string.Format("{0}", result), Guid.Empty) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id };
return new PropertyResult(alias, string.Format("{0}", result)) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id };
}
}
}
@@ -188,7 +188,7 @@ namespace umbraco.MacroEngines
}
if (result != null)
{
return new PropertyResult(alias, string.Format("{0}", result), Guid.Empty) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id };
return new PropertyResult(alias, string.Format("{0}", result)) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id };
}
}
}

View File

@@ -16,7 +16,7 @@ namespace umbraco.MacroEngines
[Obsolete("This class has been superceded by Umbraco.Core.Dynamics.DynamicNull")]
public class DynamicNull : DynamicObject, IEnumerable, IHtmlString
{
private readonly Umbraco.Core.Dynamics.DynamicNull _inner = new Umbraco.Core.Dynamics.DynamicNull();
private readonly Umbraco.Core.Dynamics.DynamicNull _inner = Umbraco.Core.Dynamics.DynamicNull.Null;
public IEnumerator GetEnumerator()
{

View File

@@ -141,7 +141,7 @@ namespace umbraco.MacroEngines
}
Values.Add(result.Current.Name, value);
propertyExists = true;
return new PropertyResult(alias, value, Guid.Empty);
return new PropertyResult(alias, value);
}
}
}
@@ -376,7 +376,7 @@ namespace umbraco.MacroEngines
return Values
.Where(kvp => !internalProperties.Contains(kvp.Key))
.ToList()
.ConvertAll(kvp => new PropertyResult(kvp.Key, kvp.Value, Guid.Empty))
.ConvertAll(kvp => new PropertyResult(kvp.Key, kvp.Value))
.Cast<IProperty>()
.ToList();
}
@@ -473,7 +473,7 @@ namespace umbraco.MacroEngines
|| Values.TryGetValue(alias, out value))
{
propertyExists = true;
return new PropertyResult(alias, value, Guid.Empty);
return new PropertyResult(alias, value);
}
propertyExists = false;

View File

@@ -10,31 +10,29 @@ namespace umbraco.MacroEngines
{
public class PropertyResult : IProperty, IHtmlString
{
private string _alias;
private string _value;
private Guid _version;
private readonly string _alias;
private readonly string _value;
public PropertyResult(IProperty source)
{
if (source != null)
{
this._alias = source.Alias;
this._value = source.Value;
this._version = source.Version;
}
if (source == null) return;
_alias = source.Alias;
_value = source.Value;
}
public PropertyResult(string alias, string value, Guid version)
public PropertyResult(string alias, string value)
{
this._alias = alias;
this._value = value;
this._version = version;
_alias = alias;
_value = value;
}
public PropertyResult(Property source)
{
this._alias = source.PropertyType.Alias;
this._value = string.Format("{0}", source.Value);
this._version = source.VersionId;
_alias = source.PropertyType.Alias;
_value = source.Value.ToString();
}
public string Alias
{
get { return _alias; }
@@ -47,13 +45,14 @@ namespace umbraco.MacroEngines
public Guid Version
{
get { return _version; }
get { return Guid.Empty; }
}
public bool IsNull()
{
return Value == null;
}
public bool HasValue()
{
return !string.IsNullOrWhiteSpace(Value);
@@ -62,9 +61,9 @@ namespace umbraco.MacroEngines
public int ContextId { get; set; }
public string ContextAlias { get; set; }
// implements IHtmlString.ToHtmlString
public string ToHtmlString()
{
//Like a boss
return Value;
}
}

View File

@@ -12,15 +12,15 @@ using Property = umbraco.NodeFactory.Property;
namespace umbraco.MacroEngines.Library
{
/// <summary>
/// Extension methods for converting DynamicPublishedContent to INode
/// </summary>
/// <summary>
/// Provides extension methods for <c>IPublishedContent</c>.
/// </summary>
/// <remarks>These are dedicated to converting DynamicPublishedContent to INode.</remarks>
internal static class PublishedContentExtensions
{
internal static IProperty ConvertToNodeProperty(this IPublishedContentProperty prop)
{
internal static IProperty ConvertToNodeProperty(this IPublishedProperty prop)
{
return new PropertyResult(prop.Alias, prop.Value.ToString(), prop.Version);
return new PropertyResult(prop.Alias, prop.Value.ToString());
}
internal static INode ConvertToNode(this IPublishedContent doc)
@@ -30,7 +30,7 @@ namespace umbraco.MacroEngines.Library
}
/// <summary>
/// Internal custom INode class used for conversions from DynamicPublishedContent
/// Internal custom INode class used for conversions from DynamicPublishedContent.
/// </summary>
private class ConvertedNode : INode
{