From 08614722a877550d7c4f7f084908d330c0d171a6 Mon Sep 17 00:00:00 2001 From: Vinicius Sanchez Date: Wed, 16 Feb 2022 08:26:34 -0300 Subject: [PATCH] Added THorse.AddCallbacks([]) --- src/Horse.Core.pas | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Horse.Core.pas b/src/Horse.Core.pas index 10c0975..b123099 100644 --- a/src/Horse.Core.pas +++ b/src/Horse.Core.pas @@ -61,7 +61,10 @@ THorseCore = class constructor Create; virtual; class function ToModule: THorseModule; class destructor UnInitialize; {$IFNDEF FPC}virtual; {$ENDIF} + class function AddCallback(ACallback: THorseCallback): THorseCore; + class function AddCallbacks(ACallbacks: TArray): THorseCore; + class function Group(): IHorseCoreGroup; class function Route(APath: string): IHorseCoreRoute; class function Use(APath: string; ACallback: THorseCallback): THorseCore; overload; @@ -128,12 +131,21 @@ implementation class function THorseCore.AddCallback(ACallback: THorseCallback): THorseCore; begin - result := GetDefaultHorse; + Result := GetDefaultHorse; if FCallbacks = nil then - FCallbacks := TList.create; + FCallbacks := TList.Create; FCallbacks.Add(ACallback); end; +class function THorseCore.AddCallbacks(ACallbacks: TArray): THorseCore; +var + LCallback: THorseCallback; +begin + for LCallback in ACallbacks do + AddCallback(LCallback); + Result := GetDefaultHorse; +end; + constructor THorseCore.Create; begin if FDefaultHorse <> nil then