2020-10-21 14:02:20 +02:00
|
|
|
using System;
|
|
|
|
using System.Reflection;
|
2020-11-17 13:46:23 +01:00
|
|
|
using BTCPayServer.Abstractions.Contracts;
|
2020-10-21 14:02:20 +02:00
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
2020-11-17 13:46:23 +01:00
|
|
|
namespace BTCPayServer.Abstractions.Models
|
2020-10-21 14:02:20 +02:00
|
|
|
{
|
|
|
|
public abstract class BaseBTCPayServerPlugin : IBTCPayServerPlugin
|
|
|
|
{
|
2023-01-11 14:35:45 +01:00
|
|
|
public virtual string Identifier
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return GetType().GetTypeInfo().Assembly.GetName().Name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public virtual string Name
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return GetType().GetTypeInfo().Assembly
|
|
|
|
.GetCustomAttribute<AssemblyTitleAttribute>()?
|
|
|
|
.Title ?? string.Empty;
|
|
|
|
}
|
|
|
|
}
|
2020-10-21 14:02:20 +02:00
|
|
|
|
|
|
|
public virtual Version Version
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2023-01-11 14:35:45 +01:00
|
|
|
return GetVersion(GetType().GetTypeInfo().Assembly
|
|
|
|
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
|
|
|
|
.InformationalVersion) ??
|
|
|
|
Assembly.GetAssembly(GetType())?.GetName()?.Version ??
|
|
|
|
new Version(1, 0, 0, 0);
|
2020-10-21 14:02:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-11 14:35:45 +01:00
|
|
|
private static Version GetVersion(string informationalVersion)
|
|
|
|
{
|
|
|
|
if (informationalVersion is null)
|
|
|
|
return null;
|
|
|
|
Version.TryParse(informationalVersion, out var r);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual string Description
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return GetType().GetTypeInfo().Assembly
|
|
|
|
.GetCustomAttribute<AssemblyDescriptionAttribute>()?
|
|
|
|
.Description ?? string.Empty;
|
|
|
|
}
|
|
|
|
}
|
2020-10-21 14:02:20 +02:00
|
|
|
public bool SystemPlugin { get; set; }
|
2020-11-05 15:43:14 +01:00
|
|
|
public virtual IBTCPayServerPlugin.PluginDependency[] Dependencies { get; } = Array.Empty<IBTCPayServerPlugin.PluginDependency>();
|
2020-10-21 14:02:20 +02:00
|
|
|
|
|
|
|
public virtual void Execute(IApplicationBuilder applicationBuilder,
|
|
|
|
IServiceProvider applicationBuilderApplicationServices)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void Execute(IServiceCollection applicationBuilder)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|