Инструменты пользователя

Инструменты сайта


works:programmer:delphi:delphi-public-interface

Delphi - Публичные интерфейсы, на примере Spring.Container

program Demo;
 
{$APPTYPE CONSOLE}
 
uses
  Classes,
  Spring.Container,
  Spring.Container.Resolvers;
 
type
  IUserUpgrader = interface
    ['{ADC36759-6E40-417D-B6F7-5DCADF8B9C07}']
  end;
 
  TUser = class(TObject);
 
  TUserProcessor = class(TInterfacedObject, IUserUpgrader)
  public
    constructor Create(AUser: TUser);
  end;
 
constructor TUserProcessor.Create(AUser: TUser);
begin
  Writeln('called constructor with passed user');
end;
 
begin
  GlobalContainer.RegisterType<TUserProcessor>.Implements<IUserUpgrader>;
  GlobalContainer.Build;
 
  GlobalContainer.Resolve<IUserUpgrader>(
    TOrderedParametersOverride.Create([TUser.Create]));
 
  GlobalContainer.Resolve<IUserUpgrader>(
    TParameterOverride.Create('AUser', TUser.Create));
 
  Readln;
end.
works/programmer/delphi/delphi-public-interface.txt · Последнее изменение: 2021/12/22 03:50 — 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki