moves ResolveUrlsFromTextString to TemplateUtilities class and obsoletes other ones.
Fixes an issue if content cache is stored in codegen folder and not in med trust.
Updates the XmlDocument (IDocumentProperty) to always return a value with parsed {localLink} and resolved Urls and cache them so the parsing only happens once.
71 lines
1.8 KiB
C#
71 lines
1.8 KiB
C#
using System;
|
|
using Umbraco.Core.Models;
|
|
using umbraco.interfaces;
|
|
using System.Web;
|
|
|
|
namespace Umbraco.Core.Dynamics
|
|
{
|
|
internal class PropertyResult : IDocumentProperty, IHtmlString
|
|
{
|
|
internal PropertyResult(IDocumentProperty source, PropertyResultType type)
|
|
{
|
|
if (source == null) throw new ArgumentNullException("source");
|
|
|
|
Alias = source.Alias;
|
|
Value = source.Value;
|
|
Version = source.Version;
|
|
PropertyType = type;
|
|
}
|
|
internal PropertyResult(string alias, object value, Guid version, PropertyResultType type)
|
|
{
|
|
if (alias == null) throw new ArgumentNullException("alias");
|
|
if (value == null) throw new ArgumentNullException("value");
|
|
|
|
Alias = alias;
|
|
Value = value;
|
|
Version = version;
|
|
PropertyType = type;
|
|
}
|
|
|
|
internal PropertyResultType PropertyType { get; private set; }
|
|
|
|
public string Alias { get; private set; }
|
|
|
|
public object Value { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Returns the value as a string output, this is used in the final rendering process of a property
|
|
/// </summary>
|
|
internal string ValueAsString
|
|
{
|
|
get
|
|
{
|
|
return Value == null ? "" : Convert.ToString(Value);
|
|
}
|
|
}
|
|
|
|
public Guid Version { get; private set; }
|
|
|
|
|
|
public bool HasValue()
|
|
{
|
|
return !ValueAsString.IsNullOrWhiteSpace();
|
|
}
|
|
|
|
/// <summary>
|
|
/// The Id of the document for which this property belongs to
|
|
/// </summary>
|
|
public int DocumentId { get; set; }
|
|
|
|
/// <summary>
|
|
/// The alias of the document type alias for which this property belongs to
|
|
/// </summary>
|
|
public string DocumentTypeAlias { get; set; }
|
|
|
|
public string ToHtmlString()
|
|
{
|
|
return ValueAsString;
|
|
}
|
|
}
|
|
}
|