baseline: OpenMU upstream b5a0961 (fresh source)
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
// <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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user