mirror of https://github.com/abpframework/abp.git
8 changed files with 115 additions and 31 deletions
@ -0,0 +1,14 @@ |
|||||
|
using Volo.Abp.Collections; |
||||
|
|
||||
|
namespace Volo.Abp.EventBus.Distributed |
||||
|
{ |
||||
|
public class DistributedEventBusOptions |
||||
|
{ |
||||
|
public ITypeList<IEventHandler> Handlers { get; } |
||||
|
|
||||
|
public DistributedEventBusOptions() |
||||
|
{ |
||||
|
Handlers = new TypeList<IEventHandler>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using JetBrains.Annotations; |
||||
|
|
||||
|
namespace Volo.Abp.EventBus |
||||
|
{ |
||||
|
[AttributeUsage(AttributeTargets.Class)] |
||||
|
public class EventNameAttribute : Attribute, IEventNameProvider |
||||
|
{ |
||||
|
public string Name { get; } |
||||
|
|
||||
|
public EventNameAttribute([NotNull] string name) |
||||
|
{ |
||||
|
Name = Check.NotNullOrWhiteSpace(name, nameof(name)); |
||||
|
} |
||||
|
|
||||
|
public static string GetName<TEvent>() |
||||
|
{ |
||||
|
return GetName(typeof(TEvent)); |
||||
|
} |
||||
|
|
||||
|
public static string GetName([NotNull] Type eventType) |
||||
|
{ |
||||
|
Check.NotNull(eventType, nameof(eventType)); |
||||
|
|
||||
|
return eventType |
||||
|
.GetCustomAttributes(true) |
||||
|
.OfType<IEventNameProvider>() |
||||
|
.FirstOrDefault() |
||||
|
?.Name |
||||
|
?? eventType.FullName; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public interface IEventNameProvider |
||||
|
{ |
||||
|
string Name { get; } |
||||
|
} |
||||
|
} |
||||
@ -1,12 +1,12 @@ |
|||||
using Volo.Abp.Collections; |
using Volo.Abp.Collections; |
||||
|
|
||||
namespace Volo.Abp.EventBus |
namespace Volo.Abp.EventBus.Local |
||||
{ |
{ |
||||
public class EventBusOptions |
public class LocalEventBusOptions |
||||
{ |
{ |
||||
public ITypeList<IEventHandler> Handlers { get; } |
public ITypeList<IEventHandler> Handlers { get; } |
||||
|
|
||||
public EventBusOptions() |
public LocalEventBusOptions() |
||||
{ |
{ |
||||
Handlers = new TypeList<IEventHandler>(); |
Handlers = new TypeList<IEventHandler>(); |
||||
} |
} |
||||
Loading…
Reference in new issue