mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-07-31 01:40:42 +00:00
Managers
This commit is contained in:
@@ -7,7 +7,10 @@ namespace Esiur.Resource;
|
||||
/// Associates a registered auditing-manager implementation with a resource type.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
|
||||
public sealed class AuditingManagerAttribute<T> : Attribute
|
||||
public sealed class AuditingManagerAttribute<T> : ResourceManagerAttribute
|
||||
where T : IAuditingManager
|
||||
{
|
||||
public AuditingManagerAttribute() : base(typeof(T))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,10 @@ namespace Esiur.Resource;
|
||||
/// Associates a registered permissions-manager implementation with a resource type.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
|
||||
public sealed class PermissionsManagerAttribute<T> : Attribute
|
||||
public sealed class PermissionsManagerAttribute<T> : ResourceManagerAttribute
|
||||
where T : IPermissionsManager
|
||||
{
|
||||
public PermissionsManagerAttribute() : base(typeof(T))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,10 @@ namespace Esiur.Resource;
|
||||
/// Associates a registered rate-control-manager implementation with a resource type.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
|
||||
public sealed class RateControlManagerAttribute<T> : Attribute
|
||||
public sealed class RateControlManagerAttribute<T> : ResourceManagerAttribute
|
||||
where T : IRateControlManager
|
||||
{
|
||||
public RateControlManagerAttribute() : base(typeof(T))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using Esiur.Security.Management;
|
||||
using System;
|
||||
|
||||
namespace Esiur.Resource;
|
||||
|
||||
/// <summary>
|
||||
/// Base metadata used to resolve a resource manager from its owning Warehouse.
|
||||
/// Manager attributes never create instances directly; the declared type must be
|
||||
/// registered with the Warehouse before the resource is created.
|
||||
/// </summary>
|
||||
public abstract class ResourceManagerAttribute : Attribute
|
||||
{
|
||||
public Type ManagerType { get; }
|
||||
|
||||
protected ResourceManagerAttribute(Type managerType)
|
||||
{
|
||||
ManagerType = managerType ?? throw new ArgumentNullException(nameof(managerType));
|
||||
|
||||
if (!typeof(IResourceManager).IsAssignableFrom(managerType))
|
||||
throw new ArgumentException(
|
||||
$"Manager type `{managerType}` must implement {nameof(IResourceManager)}.",
|
||||
nameof(managerType));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user