Skip to content

Commit

Permalink
Merge pull request #882 from unoplatform/dev/nr/modelsuffix
Browse files Browse the repository at this point in the history
feat: Including Model in view model suffix
  • Loading branch information
nickrandolph authored Nov 2, 2022
2 parents 22b889a + f1f228e commit 4f90d1b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Uno.Extensions.Navigation.UI/RouteResolverDefault.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class RouteResolverDefault : RouteResolver

public string[] ViewSuffixes { get; set; } = new[] { "View", "Page", "Control", "Flyout", "Dialog", "Popup" };

public string[] ViewModelSuffixes { get; set; } = new[] { "ViewModel", "VM" };
public string[] ViewModelSuffixes { get; set; } = new[] { "Model", "ViewModel", "VM" };

private IDictionary<string, Type>? loadedTypes;

Expand Down Expand Up @@ -189,12 +189,17 @@ private string TrimSuffices(string? path, IEnumerable<string> suffixes)
return string.Empty;
}

var best = path;
foreach (var item in suffixes)
{
path = path.TrimEnd(item, StringComparison.InvariantCultureIgnoreCase);
var candidate = path.TrimEnd(item, StringComparison.InvariantCultureIgnoreCase);
if (candidate.Length < best.Length)
{
best = candidate;
}
}

return path;
return best;
}

public IDictionary<string, Type> LoadedTypes
Expand Down

0 comments on commit 4f90d1b

Please sign in to comment.