更新整理
This commit is contained in:
26
WPFluent.Gallery/Helpers/NameToPageTypeConverter.cs
Normal file
26
WPFluent.Gallery/Helpers/NameToPageTypeConverter.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
// 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)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user