mirror of
https://github.com/babalae/better-genshin-impact
synced 2025-01-08 11:57:53 +08:00
21 lines
457 B
C#
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)!;
|
|
}
|
|
}
|