mirror of https://github.com/abpframework/abp.git
12 changed files with 207 additions and 33 deletions
@ -0,0 +1,25 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.DependencyInjection; |
|||
|
|||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] |
|||
public class ExposeKeyedServiceAttribute<TServiceType> : Attribute, IExposedKeyedServiceTypesProvider |
|||
where TServiceType : class |
|||
{ |
|||
public ServiceIdentifier ServiceIdentifier { get; } |
|||
|
|||
public ExposeKeyedServiceAttribute(object serviceKey) |
|||
{ |
|||
if (serviceKey == null) |
|||
{ |
|||
throw new AbpException($"{nameof(serviceKey)} can not be null! Use {nameof(ExposeServicesAttribute)} instead."); |
|||
} |
|||
|
|||
ServiceIdentifier = new ServiceIdentifier(serviceKey, typeof(TServiceType)); |
|||
} |
|||
|
|||
public ServiceIdentifier[] GetExposedServiceTypes(Type targetType) |
|||
{ |
|||
return new[] { ServiceIdentifier }; |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.DependencyInjection; |
|||
|
|||
public interface IExposedKeyedServiceTypesProvider |
|||
{ |
|||
ServiceIdentifier[] GetExposedServiceTypes(Type targetType); |
|||
} |
|||
Loading…
Reference in new issue