// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; namespace osu.Game.Tests.Visual { /// /// A which providing ad-hoc dependencies to the child drawables. /// /// /// The must be set while this is not loaded. /// public partial class DependencyProvidingContainer : Container { /// /// The dependencies provided to the children. /// public (Type, object)[] CachedDependencies { get; init; } = Array.Empty<(Type, object)>(); protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { var dependencyContainer = new DependencyContainer(base.CreateChildDependencies(parent)); foreach ((var type, object value) in CachedDependencies) dependencyContainer.CacheAs(type, value); return dependencyContainer; } } }