OnCreateEventId (class)

De Wiki1000

(Version 11)

class function OnCreateEventID():string;

Retire l'identifiant de l'évènement de création d'un objet de cette classe.

Return L'identifiant de l'évènement

Exemple

Type
  MyClass = class(TdbObject)
   //...
   property CanStart:boolean; 
  end;  
 
  MyTask = class(TitTask)
    Function Execute():boolean;
    Function doExecute(obj:TitObject):boolean;
  end;
 
Function MyTask.Execute():boolean;
var aMsg:TdbmQueueMessage; 
begin
  Result := False; 
  aMsg := ReceivedMsg as TdbmQueueMessage;
  if Assigned(aMsg) then
   begin
     if Assigned(SourceObject) then
      begin
        Result := doExecute(SourceObject);                  
       end; 
   end;
end;
 
Function MyTask.doExecute(obj:TitObject):boolean;
begin
  if obj is MyClass then
   begin
     if (obj as MyClass).CanStart then 
      begin
        AddMessage(Format('object %s ...',[(obj as MyClass).Caption])); 
        // do something ...  
      end
      else
      begin
        AddMessage(Format('objet %s ne peut pas ...'),[(obj as MyClass).Caption])); 
      end; 
     Result := True;
   end
   else Result := False; 
end;
 
//procedure RegisterTasks;
begin
  MyClass.RegisterOnCreateEvent();
 
  MyTask.Subscribe(
    MyClass.OnCreateEventId(),
    [],[]
  );
end;

Voir aussi :


Classes métiers (tech)Développement DSM

Outils personnels