Skip to content

Commit

Permalink
overloads in TranslatedInstanceLogic.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
olmobrutall committed Jun 25, 2022
1 parent 31f7f64 commit 7a268b9
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions Signum.Engine.Extensions/Translation/TranslatedInstanceLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,22 @@ where ti.PropertyRoute.RootType.Is(typeof(T).ToTypeEntity()) && ti.PropertyRoute
select ti).UnsafeDelete();
}

public static string? TranslatedField<T>(this T entity, Expression<Func<T, string?>> property) where T : Entity
public static string TranslatedField<T>(this T entity, Expression<Func<T, string>> property) where T : Entity
{
string? fallbackString = TranslatedInstanceLogic.GetPropertyRouteAccesor(property)(entity);

return entity.ToLite().TranslatedField(property, fallbackString);
var pr = PropertyRoute.Construct(property);

return entity.ToLite().TranslatedField(pr, fallbackString);
}

public static string? TranslatedFieldNullable<T>(this T entity, Expression<Func<T, string?>> property) where T : Entity
{
string? fallbackString = TranslatedInstanceLogic.GetPropertyRouteAccesor(property)(entity);

var pr = PropertyRoute.Construct(property);

return entity.ToLite().TranslatedField(pr, fallbackString);
}

public static IEnumerable<TranslatableElement<T>> TranslatedMList<E, T>(this E entity, Expression<Func<E, MList<T>>> mlistProperty) where E : Entity
Expand All @@ -289,7 +300,16 @@ public static IEnumerable<TranslatableElement<T>> TranslatedMList<E, T>(this E e
}
}

public static string? TranslatedElement<T>(this TranslatableElement<T> element, Expression<Func<T, string?>> property)
public static string TranslatedElement<T>(this TranslatableElement<T> element, Expression<Func<T, string>> property)
{
string fallback = GetPropertyRouteAccesor(property)(element.Value);

PropertyRoute route = element.ElementRoute.Continue(property);

return TranslatedField(element.Lite, route, element.RowId, fallback);
}

public static string? TranslatedElementNullable<T>(this TranslatableElement<T> element, Expression<Func<T, string?>> property)
{
string? fallback = GetPropertyRouteAccesor(property)(element.Value);

Expand Down

0 comments on commit 7a268b9

Please sign in to comment.