protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { headlessHostStorage = (parent.Get <GameHost>() as HeadlessGameHost)?.Storage; Resources = parent.Get <OsuGameBase>().Resources; contextFactory = new Lazy <DatabaseContextFactory>(() => { var factory = new DatabaseContextFactory(LocalStorage); using (var usage = factory.Get()) usage.Migrate(); return(factory); }); RecycleLocalStorage(false); var baseDependencies = base.CreateChildDependencies(parent); // to isolate ruleset configs in tests from the actual database and avoid state pollution problems, // as well as problems due to the implementation details of the "real" implementation (the configs only being available at `LoadComplete()`), // cache a test implementation of the ruleset config cache over the "real" one. var isolatedBaseDependencies = new DependencyContainer(baseDependencies); isolatedBaseDependencies.CacheAs(RulesetConfigs = new TestRulesetConfigCache()); baseDependencies = isolatedBaseDependencies; var providedRuleset = CreateRuleset(); if (providedRuleset != null) { baseDependencies = rulesetDependencies = new DrawableRulesetDependencies(providedRuleset, baseDependencies); } Dependencies = new OsuScreenDependencies(false, baseDependencies); Beatmap = Dependencies.Beatmap; Beatmap.SetDefault(); Ruleset = Dependencies.Ruleset; Ruleset.SetDefault(); SelectedMods = Dependencies.Mods; SelectedMods.SetDefault(); if (!UseOnlineAPI) { dummyAPI = new DummyAPIAccess(); Dependencies.CacheAs <IAPIProvider>(dummyAPI); base.Content.Add(dummyAPI); } return(Dependencies); }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { var host = parent.Get <GameHost>(); headlessHostStorage = (host as HeadlessGameHost)?.Storage; Resources = parent.Get <OsuGameBase>().Resources; realm = new Lazy <RealmAccess>(() => new RealmAccess(LocalStorage, OsuGameBase.CLIENT_DATABASE_FILENAME, host.UpdateThread)); RecycleLocalStorage(false); var baseDependencies = base.CreateChildDependencies(parent); // to isolate ruleset configs in tests from the actual database and avoid state pollution problems, // as well as problems due to the implementation details of the "real" implementation (the configs only being available at `LoadComplete()`), // cache a test implementation of the ruleset config cache over the "real" one. var isolatedBaseDependencies = new DependencyContainer(baseDependencies); isolatedBaseDependencies.CacheAs(RulesetConfigs = new TestRulesetConfigCache()); baseDependencies = isolatedBaseDependencies; var providedRuleset = CreateRuleset(); if (providedRuleset != null) { isolatedBaseDependencies = rulesetDependencies = new DrawableRulesetDependencies(providedRuleset, baseDependencies); } Dependencies = isolatedBaseDependencies; Beatmap.Default = parent.Get <Bindable <WorkingBeatmap> >().Default; Beatmap.SetDefault(); Ruleset.Value = CreateRuleset()?.RulesetInfo ?? parent.Get <RulesetStore>().AvailableRulesets.First(); SelectedMods.SetDefault(); if (!UseOnlineAPI) { dummyAPI = new DummyAPIAccess(); Dependencies.CacheAs <IAPIProvider>(dummyAPI); base.Content.Add(dummyAPI); } return(Dependencies); }