Files
Shrlalgo.RvKits/WPFluent.Gallery/Helpers/NameToPageTypeConverter.cs
2025-04-24 20:56:44 +08:00

27 lines
883 B
C#

// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Reflection;
namespace WPFluent.Gallery.Helpers;
internal sealed class NameToPageTypeConverter
{
private static readonly Type[] PageTypes = Assembly
.GetExecutingAssembly()
.GetTypes()
.Where(t => t.Namespace?.StartsWith("WPFluent.Gallery.Views.Pages") ?? false)
.ToArray();
public static Type? Convert(string pageName)
{
pageName = pageName.Trim().ToLower() + "page";
return PageTypes.FirstOrDefault(singlePageType =>
singlePageType.Name.Equals(pageName, StringComparison.CurrentCultureIgnoreCase)
);
}
}