Now use empty string for invariant in published
This commit is contained in:
@@ -10,18 +10,18 @@
|
||||
/// </summary>
|
||||
public CurrentVariation(string culture = null, string segment = null)
|
||||
{
|
||||
Culture = culture;
|
||||
Segment = segment;
|
||||
Culture = culture ?? ""; // cannot be null, default to invariant
|
||||
Segment = segment ?? ""; // cannot be null, default to neutral
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the culture.
|
||||
/// </summary>
|
||||
public string Culture { get; set; }
|
||||
public string Culture { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the segment.
|
||||
/// </summary>
|
||||
public string Segment { get; set; }
|
||||
public string Segment { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,12 +117,12 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
/// if any. In addition, when the content type is multi-lingual, this is the url for the
|
||||
/// specified culture. Otherwise, it is the invariant url.</para>
|
||||
/// </remarks>
|
||||
string GetUrl(string culture = ".");
|
||||
string GetUrl(string culture = null);
|
||||
|
||||
/// <summary>
|
||||
/// Gets culture infos for a culture.
|
||||
/// </summary>
|
||||
PublishedCultureInfos GetCulture(string culture = ".");
|
||||
PublishedCultureInfos GetCulture(string culture = null);
|
||||
|
||||
/// <summary>
|
||||
/// Gets culture infos.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
/// <para>Other caches that get their raw value from the database would consider that a property has "no
|
||||
/// value" if it is missing, null, or an empty string (including whitespace-only).</para>
|
||||
/// </remarks>
|
||||
bool HasValue(string culture = ".", string segment = ".");
|
||||
bool HasValue(string culture = null, string segment = null);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the source value of the property.
|
||||
@@ -35,7 +35,7 @@
|
||||
/// <para>If you're using that value, you're probably wrong, unless you're doing some internal
|
||||
/// Umbraco stuff.</para>
|
||||
/// </remarks>
|
||||
object GetSourceValue(string culture = ".", string segment = ".");
|
||||
object GetSourceValue(string culture = null, string segment = null);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the object value of the property.
|
||||
@@ -45,7 +45,7 @@
|
||||
/// <para>It can be null, or any type of CLR object.</para>
|
||||
/// <para>It has been fully prepared and processed by the appropriate converter.</para>
|
||||
/// </remarks>
|
||||
object GetValue(string culture = ".", string segment = ".");
|
||||
object GetValue(string culture = null, string segment = null);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the XPath value of the property.
|
||||
@@ -55,6 +55,6 @@
|
||||
/// <para>It must be either null, or a string, or an XPathNavigator.</para>
|
||||
/// <para>It has been fully prepared and processed by the appropriate converter.</para>
|
||||
/// </remarks>
|
||||
object GetXPathValue(string culture = ".", string segment = ".");
|
||||
object GetXPathValue(string culture = null, string segment = null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,10 +97,10 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
public virtual string Url => _content.Url;
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual string GetUrl(string culture = ".") => _content.GetUrl(culture);
|
||||
public virtual string GetUrl(string culture = null) => _content.GetUrl(culture);
|
||||
|
||||
/// <inheritdoc />
|
||||
public PublishedCultureInfos GetCulture(string culture = ".") => _content.GetCulture(culture);
|
||||
public PublishedCultureInfos GetCulture(string culture = null) => _content.GetCulture(culture);
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyDictionary<string, PublishedCultureInfos> Cultures => _content.Cultures;
|
||||
|
||||
@@ -53,15 +53,15 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
public string Alias => PropertyType.Alias;
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract bool HasValue(string culture = ".", string segment = ".");
|
||||
public abstract bool HasValue(string culture = null, string segment = null);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract object GetSourceValue(string culture = ".", string segment = ".");
|
||||
public abstract object GetSourceValue(string culture = null, string segment = null);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract object GetValue(string culture = ".", string segment = ".");
|
||||
public abstract object GetValue(string culture = null, string segment = null);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract object GetXPathValue(string culture = ".", string segment = ".");
|
||||
public abstract object GetXPathValue(string culture = null, string segment = null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,20 +23,20 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
// RawValueProperty does not (yet?) support variants,
|
||||
// only manages the current "default" value
|
||||
|
||||
public override object GetSourceValue(string culture = ".", string segment = ".")
|
||||
=> culture == "." & segment == "." ? _sourceValue : null;
|
||||
public override object GetSourceValue(string culture = null, string segment = null)
|
||||
=> string.IsNullOrEmpty(culture) & string.IsNullOrEmpty(segment) ? _sourceValue : null;
|
||||
|
||||
public override bool HasValue(string culture = ".", string segment = ".")
|
||||
public override bool HasValue(string culture = null, string segment = null)
|
||||
{
|
||||
var sourceValue = GetSourceValue(culture, segment);
|
||||
return sourceValue is string s ? !string.IsNullOrWhiteSpace(s) : sourceValue != null;
|
||||
}
|
||||
|
||||
public override object GetValue(string culture = ".", string segment = ".")
|
||||
=> culture == "." & segment == "." ? _objectValue.Value : null;
|
||||
public override object GetValue(string culture = null, string segment = null)
|
||||
=> string.IsNullOrEmpty(culture) & string.IsNullOrEmpty(segment) ? _objectValue.Value : null;
|
||||
|
||||
public override object GetXPathValue(string culture = ".", string segment = ".")
|
||||
=> culture == "." & segment == "." ? _xpathValue.Value : null;
|
||||
public override object GetXPathValue(string culture = null, string segment = null)
|
||||
=> string.IsNullOrEmpty(culture) & string.IsNullOrEmpty(segment) ? _xpathValue.Value : null;
|
||||
|
||||
public RawValueProperty(PublishedPropertyType propertyType, IPublishedElement content, object sourceValue, bool isPreviewing = false)
|
||||
: base(propertyType, PropertyCacheLevel.Unknown) // cache level is ignored
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
|
||||
public CurrentVariation CurrentVariation
|
||||
{
|
||||
get => _contexts.GetOrAdd(Thread.CurrentThread.CurrentUICulture.Name, culture => new CurrentVariation { Culture = culture });
|
||||
get => _contexts.GetOrAdd(Thread.CurrentThread.CurrentUICulture.Name, culture => new CurrentVariation(culture));
|
||||
set => throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user