Do you have any tutorials on Code-First services in Delphi?

Hi!

I am wondering if there is any documentation about that.

Thanks!

A

we have Code-First Servers article.

after you have created Code-First project with Wizard, _impl file will contain this quick reference:

  some useful attributes:
  [ROSkip] - type with this attribute will be skiped at generating RODL for client-side
  [RORole('allow_role')]  - service&service methods only
  [RORole('!deny_role')]  - service&service methods only
  [ROCustom('myname','myvalue')] - custom attributes
  [ROService('name')] - service identificator
  [ROServiceMethod]   - service method identificator
  [ROEventSink]       - event sink identificator

  examples:
  TMyStruct = class(TROComplexType)
  private
    fA: Integer;
  published
    property A :Integer read fA write fA;
  end;

  TMyStructArray = class(TROArray<TMyStruct>);

  [ROEventSink]
  IMyEvents = interface(IROEventSink)
    ['{75F9A466-518A-4B09-9DC4-9272B1EEFD95}']
    procedure OnMyEvent(const aStr: String);
  end;

  simple usage of event sinks:
    //ev: IROEventWriter<IMyEvents>;
    ..
    ev := EventRepository.GetWriter<IMyEvents>(Session.SessionID);
    ev.Event.OnMyEvent('Message');

To save others the frustration that I just had, you need to include the unit uRORTTIServerSupport to get the ev variable to compile. The compiler knew IROEventWriter on its own, but not with the iMyEvents too.

To get the [ROEventSink] attribute compiling in your events interface, include uRORTTIAttributes in the uses clause. All working now!

Code-First wizard generates _Impl with uRORTTIAttributes, uRORTTIServerSupport, in uses section so seems this problem was already solved.

I’m glad to hear it