mirror of
https://github.com/ZuneDev/ZuneModdingHelper.git
synced 2026-07-27 13:12:21 -07:00
Create GetAvailableMods overload
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using ZuneModCore.Mods;
|
using ZuneModCore.Mods;
|
||||||
|
|
||||||
namespace ZuneModCore;
|
namespace ZuneModCore;
|
||||||
|
|
||||||
public class ModManager
|
public class ModManager
|
||||||
{
|
{
|
||||||
|
private static List<Mod>? _mods;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Factories for all available mods.
|
/// Factories for all available mods.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -17,13 +20,20 @@ public class ModManager
|
|||||||
new MbidLocatorModFactory(),
|
new MbidLocatorModFactory(),
|
||||||
}.AsReadOnly();
|
}.AsReadOnly();
|
||||||
|
|
||||||
private static List<Mod>? _mods;
|
/// <summary>
|
||||||
public static IReadOnlyList<Mod> GetAvailableMods()
|
/// Creates instances of each mod using the available factories
|
||||||
|
/// using the default MVVM IoC instance.
|
||||||
|
/// </summary>
|
||||||
|
public static IReadOnlyList<Mod> GetAvailableMods() => GetAvailableMods(CommunityToolkit.Mvvm.DependencyInjection.Ioc.Default);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates instances of each mod using the available factories.
|
||||||
|
/// </summary>
|
||||||
|
public static IReadOnlyList<Mod> GetAvailableMods(IServiceProvider services)
|
||||||
{
|
{
|
||||||
if (_mods is null)
|
if (_mods is null)
|
||||||
{
|
{
|
||||||
_mods = new(ModFactories.Count);
|
_mods = new(ModFactories.Count);
|
||||||
var services = CommunityToolkit.Mvvm.DependencyInjection.Ioc.Default;
|
|
||||||
|
|
||||||
foreach (var modType in ModFactories)
|
foreach (var modType in ModFactories)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user