Browse Source

only store runtime platform when requested

pull/11158/head
Emmanuel Hansen 3 years ago
parent
commit
75cbab78ad
  1. 7
      src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs

7
src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs

@ -50,7 +50,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.Runtime
private readonly IServiceProvider? _parentProvider;
private readonly List<IResourceNode>? _parentResourceNodes;
private readonly INameScope _nameScope;
private readonly IRuntimePlatform? _runtimePlatform;
private IRuntimePlatform? _runtimePlatform;
public DeferredParentServiceProvider(IServiceProvider? parentProvider, List<IResourceNode>? parentResourceNodes,
object rootObject, INameScope nameScope)
@ -59,7 +59,6 @@ namespace Avalonia.Markup.Xaml.XamlIl.Runtime
_parentResourceNodes = parentResourceNodes;
_nameScope = nameScope;
RootObject = rootObject;
_runtimePlatform = AvaloniaLocator.Current.GetService<IRuntimePlatform>();
}
public IEnumerable<object> Parents => GetParents();
@ -83,7 +82,11 @@ namespace Avalonia.Markup.Xaml.XamlIl.Runtime
if (serviceType == typeof(IAvaloniaXamlIlControlTemplateProvider))
return this;
if (serviceType == typeof(IRuntimePlatform))
{
if(_runtimePlatform == null)
_runtimePlatform = AvaloniaLocator.Current.GetService<IRuntimePlatform>();
return _runtimePlatform;
}
return _parentProvider?.GetService(serviceType);
}

Loading…
Cancel
Save