better-genshin-impact/BetterGenshinImpact/Markup/ServiceLocatorExtension.cs
2024-08-14 18:01:02 +08:00

21 lines
457 B
C#

using System;
using System.Windows.Markup;
namespace BetterGenshinImpact.Markup;
[MarkupExtensionReturnType(typeof(object))]
public class ServiceLocatorExtension : MarkupExtension
{
public Type Type { get; set; } = null!;
public ServiceLocatorExtension()
{
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
ArgumentNullException.ThrowIfNull(Type);
return App.GetService(Type)!;
}
}