Skip to content

Commit

Permalink
#7469 - Fixed Ambiguous extension method issue by renaming our extens…
Browse files Browse the repository at this point in the history
…ion method from Value to GetValue
  • Loading branch information
bergmania committed Jan 17, 2020
1 parent 5ddc4b8 commit 6637bf5
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ public static class PublishedElementExtensions
/// <summary>
/// Gets the value of a property.
/// </summary>
public static TValue Value<TModel, TValue>(this TModel model, Expression<Func<TModel, TValue>> property, string culture = null, string segment = null, Fallback fallback = default, TValue defaultValue = default)
public static TValue GetValue<TModel, TValue>(this TModel model, Expression<Func<TModel, TValue>> property, string culture = null, string segment = null, Fallback fallback = default, TValue defaultValue = default)
where TModel : IPublishedElement
{
var alias = GetAlias(model, property);
return model.Value<TValue>(alias, culture, segment, fallback, defaultValue);
}

// fixme that one should be public so ppl can use it
private static string GetAlias<TModel, TValue>(TModel model, Expression<Func<TModel, TValue>> property)
{
if (property.NodeType != ExpressionType.Lambda)
Expand All @@ -45,7 +44,7 @@ private static string GetAlias<TModel, TValue>(TModel model, Expression<Func<TMo
var attribute = member.GetCustomAttribute<ImplementPropertyTypeAttribute>();
if (attribute == null)
throw new InvalidOperationException("Property is not marked with ImplementPropertyType attribute.");

return attribute.Alias;
}
}
Expand Down

0 comments on commit 6637bf5

Please sign in to comment.