From b9fd35051f9352148804e2f676623a2e1f30893d Mon Sep 17 00:00:00 2001 From: Emmanuel Hansen Date: Thu, 27 Apr 2023 12:41:39 +0000 Subject: [PATCH] store IRuntimePlatform in DeferredParentServiceProvider --- .../XamlIl/Runtime/XamlIlRuntimeHelpers.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs b/src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs index 0cc7cc5468..6f5e822079 100644 --- a/src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs +++ b/src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs @@ -50,6 +50,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.Runtime private readonly IServiceProvider? _parentProvider; private readonly List? _parentResourceNodes; private readonly INameScope _nameScope; + private readonly IRuntimePlatform? _runtimePlatform; public DeferredParentServiceProvider(IServiceProvider? parentProvider, List? parentResourceNodes, object rootObject, INameScope nameScope) @@ -58,6 +59,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.Runtime _parentResourceNodes = parentResourceNodes; _nameScope = nameScope; RootObject = rootObject; + _runtimePlatform = AvaloniaLocator.Current.GetService(); } public IEnumerable Parents => GetParents(); @@ -80,6 +82,8 @@ namespace Avalonia.Markup.Xaml.XamlIl.Runtime return this; if (serviceType == typeof(IAvaloniaXamlIlControlTemplateProvider)) return this; + if (serviceType == typeof(IRuntimePlatform)) + return _runtimePlatform; return _parentProvider?.GetService(serviceType); }