Refactor the handling of date time to no longer depend on a static
Build / Build (push) Successful in 10m13s
Build / Build (push) Successful in 10m13s
This commit is contained in:
11 files changed
+53
-39
No files matched your search
@@ -26,7 +26,7 @@ public interface IPlugin
|
||||
/// <summary>
|
||||
/// Run the registration of the plugin when we're building the library.
|
||||
/// </summary>
|
||||
void Register(ScriptRegistry registry);
|
||||
void Register(ScriptRegistry registry, PluginEnvironmentHelpers helpers);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IPlugin"/>
|
||||
@@ -59,7 +59,7 @@ public abstract class Plugin<TConfiguration> : IPlugin where TConfiguration : IP
|
||||
/// <summary>
|
||||
/// Run the registration of the plugin when we're building the library.
|
||||
/// </summary>
|
||||
public abstract void Register(ScriptRegistry registry);
|
||||
public abstract void Register(ScriptRegistry registry, PluginEnvironmentHelpers helpers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace PkmnLib.Dynamic.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Helper functions to get information about the environment we're running in, such as the current date time.
|
||||
/// </summary>
|
||||
public class PluginEnvironmentHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// A delegate that provides the current date and time.
|
||||
/// </summary>
|
||||
public delegate DateTimeOffset DateTimeProviderDelegate();
|
||||
|
||||
/// <summary>
|
||||
/// A function to get the current date and time. This can be replaced in cases where the date and time
|
||||
/// may not be the same as the system time.
|
||||
/// </summary>
|
||||
public required DateTimeProviderDelegate DateTimeProvider { get; init; }
|
||||
}
|
||||
Reference in new issue
Block a user