Einzelnen Beitrag anzeigen

TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.070 Beiträge
 
Delphi 10.4 Sydney
 
#6

AW: Populate Array of procedure of object

  Alt 1. Feb 2018, 11:18
Workaround:

Delphi-Quellcode:
program Project2;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,
  System.Generics.Collections;

type
  TUpdateProcedure = procedure of object;
  TUpdateProcedures = TArray<TUpdateProcedure>;

  IModelUpdater = interface
    ['{DB8D4B0F-31EA-4A93-AA06-E49FFA71BA47}']
  end;

  TReloAdapter = class(TInterfacedObject, IModelUpdater)
  private
    UpdateViewProcedures: TUpdateProcedures;
    procedure UpdateView001;
    procedure UpdateView002;
  public
    constructor Create;
  end;

var
  ReloAdapter: TReloAdapter;

constructor TReloAdapter.Create;
var
  UpdateProcedureList: TList<TUpdateProcedure>;
begin
  UpdateProcedureList:= TList<TUpdateProcedure>.Create();
  UpdateProcedureList.AddRange([UpdateView001, UpdateView002]);
  UpdateViewProcedures := UpdateProcedureList.ToArray;
  UpdateProcedureList.Free;
end;

procedure TReloAdapter.UpdateView001;
begin

end;

procedure TReloAdapter.UpdateView002;
begin

end;

begin
  try
    ReloAdapter := TReloAdapter.Create;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
  Mit Zitat antworten Zitat