@@ -24,7 +24,8 @@ interface
24
24
25
25
type
26
26
27
- TCloneEvent = TFunc<TObject,TObject>;
27
+ TCloneEventCallback = function (const AObject: TObject): TObject of object ;
28
+ TCloneEventMethod = TFunc<TObject,TObject>;
28
29
29
30
IEventBus = Interface
30
31
[' {7BDF4536-F2BA-4FBA-B186-09E1EE6C7E35}' ]
@@ -42,8 +43,8 @@ TEventBus = class(TInterfacedObject, IEventBus)
42
43
var
43
44
FTypesOfGivenSubscriber: TObjectDictionary<TObject, TList<TClass>>;
44
45
FSubscriptionsOfGivenEventType: TObjectDictionary<TClass, TObjectList<TSubscription>>;
45
- FCustomClonerDict: TDictionary<String, TCloneEvent >;
46
- FOnCloneEvent: TCloneEvent ;
46
+ FCustomClonerDict: TDictionary<String, TCloneEventMethod >;
47
+ FOnCloneEvent: TCloneEventCallback ;
47
48
procedure Subscribe (ASubscriber: TObject;
48
49
ASubscriberMethod: TSubscriberMethod);
49
50
procedure UnsubscribeByEventType (ASubscriber: TObject; AEventType: TClass);
@@ -66,8 +67,8 @@ TEventBus = class(TInterfacedObject, IEventBus)
66
67
property TypesOfGivenSubscriber: TObjectDictionary<TObject, TList<TClass>> read FTypesOfGivenSubscriber;
67
68
property SubscriptionsOfGivenEventType: TObjectDictionary<TClass, TObjectList<TSubscription>> read
68
69
FSubscriptionsOfGivenEventType;
69
- property OnCloneEvent: TCloneEvent write FOnCloneEvent;
70
- procedure AddCustomClassCloning (const AQualifiedClassName: String; const ACloneEvent: TCloneEvent );
70
+ property OnCloneEvent: TCloneEventCallback write FOnCloneEvent;
71
+ procedure AddCustomClassCloning (const AQualifiedClassName: String; const ACloneEvent: TCloneEventMethod );
71
72
procedure RemoveCustomClassCloning (const AQualifiedClassName: String);
72
73
end ;
73
74
@@ -92,7 +93,7 @@ constructor TEventBus.Create;
92
93
TObjectList < TSubscription >>.Create([doOwnsValues]);
93
94
FTypesOfGivenSubscriber := TObjectDictionary < TObject,
94
95
TList < TClass >>.Create([doOwnsValues]);
95
- FCustomClonerDict := TDictionary<String, TCloneEvent >.Create;
96
+ FCustomClonerDict := TDictionary<String, TCloneEventMethod >.Create;
96
97
end ;
97
98
98
99
destructor TEventBus.Destroy;
@@ -104,14 +105,14 @@ destructor TEventBus.Destroy;
104
105
end ;
105
106
106
107
procedure TEventBus.AddCustomClassCloning (const AQualifiedClassName: String;
107
- const ACloneEvent: TCloneEvent );
108
+ const ACloneEvent: TCloneEventMethod );
108
109
begin
109
110
FCustomClonerDict.Add(AQualifiedClassName, ACloneEvent);
110
111
end ;
111
112
112
113
function TEventBus.CloneEvent (AEvent: TObject): TObject;
113
114
var
114
- LCloneEvent: TCloneEvent ;
115
+ LCloneEvent: TCloneEventMethod ;
115
116
begin
116
117
if FCustomClonerDict.TryGetValue(AEvent.QualifiedClassName, LCloneEvent) then
117
118
Result := LCloneEvent(AEvent)
0 commit comments