Files
AdamuSw/tests/MUnique.OpenMU.PlugIns.Tests/CustomTestPlugInContainer.cs
2026-07-14 19:00:35 +03:00

47 lines
1.6 KiB
C#

// <copyright file="CustomTestPlugInContainer.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>
namespace MUnique.OpenMU.PlugIns.Tests;
/// <summary>
/// A test implementation of a <see cref="CustomPlugInContainerBase{TPlugIn}"/>.
/// </summary>
public class CustomTestPlugInContainer : CustomPlugInContainerBase<ICustomTestPlugInContainer>
{
/// <summary>
/// Initializes a new instance of the <see cref="CustomTestPlugInContainer"/> class.
/// </summary>
/// <param name="manager">The plugin manager which manages this instance.</param>
public CustomTestPlugInContainer(PlugInManager manager)
: base(manager)
{
this.Initialize();
}
/// <summary>
/// Gets or sets a value indicating whether this instance creates new plug ins in <see cref="CreatePlugInIfSuitable"/>.
/// </summary>
public bool CreateNewPlugIns { get; set; } = true;
/// <inheritdoc />
protected override void CreatePlugInIfSuitable(Type plugInType)
{
if (this.CreateNewPlugIns)
{
this.AddPlugIn((ITestCustomPlugIn)Activator.CreateInstance(plugInType)!, true);
}
}
/// <inheritdoc />
protected override ICustomTestPlugInContainer? DetermineEffectivePlugIn(Type interfaceType)
{
return this.ActivePlugIns.FirstOrDefault(interfaceType.IsInstanceOfType);
}
/// <inheritdoc />
protected override bool IsNewPlugInReplacingOld(ICustomTestPlugInContainer currentEffectivePlugIn, ICustomTestPlugInContainer activatedPlugIn)
{
return true;
}
}