Hello all and thanks in advance for your help
Is there a way to use the above BatiprixUnit.pas directly in scripts without adding it in "uses" clause of the calling program? (for example, using the ScripterProIDE demo prog without any change, create a new project for using the BatiprixUnit objects) ?
unit BatiprixUnit;
interface
uses
Pkg.Json.DTO, System.Generics.Collections, REST.Json.Types;
{$M+}
type
TElements = class;
TUnit = class;
TUnit = class
private
FDescription: string;
FLabel: string;
published
property Description: string read FDescription write FDescription;
property &Label: string read FLabel write FLabel;
end;
TElements = class(TJsonDTO)
private
FDescription: string;
FElementType: string;
[JSONName('Elements'), JSONMarshalled(False)]
FElementsArray: TArray;
[GenericListReflect]
FElements: TObjectList;
FId: Integer;
FLabel: string;
FNomenclature: string;
FOrder: Integer;
FQuantity: Double;
FTotalPrice: Double;
FUnit: TUnit;
FUnitPrice: Double;
function GetElements: TObjectList;
protected
function GetAsJson: string; override;
published
property Description: string read FDescription write FDescription;
property ElementType: string read FElementType write FElementType;
property Elements: TObjectList read GetElements;
property Id: Integer read FId write FId;
property &Label: string read FLabel write FLabel;
property Nomenclature: string read FNomenclature write FNomenclature;
property Order: Integer read FOrder write FOrder;
property Quantity: Double read FQuantity write FQuantity;
property TotalPrice: Double read FTotalPrice write FTotalPrice;
property &Unit: TUnit read FUnit;
property UnitPrice: Double read FUnitPrice write FUnitPrice;
public
constructor Create; override;
destructor Destroy; override;
end;
TOuvrages = class(TJsonDTO)
private
FCode: string;
FCostPrice: Double;
FDescription: string;
[JSONName('Elements'), JSONMarshalled(False)]
FElementsArray: TArray;
[GenericListReflect]
FElements: TObjectList;
FFlatCost: Double;
FId: Integer;
FLabel: string;
FLaborFlatCost: Double;
FLaborQuantity: Double;
FLaborUnitCost: Double;
FMillesimeId: Integer;
FNomenclature: string;
FSellingPrice: Double;
FUnit: TUnit;
function GetElements: TObjectList;
protected
function GetAsJson: string; override;
published
property Code: string read FCode write FCode;
property CostPrice: Double read FCostPrice write FCostPrice;
property Description: string read FDescription write FDescription;
property Elements: TObjectList read GetElements;
property FlatCost: Double read FFlatCost write FFlatCost;
property Id: Integer read FId write FId;
property &Label: string read FLabel write FLabel;
property LaborFlatCost: Double read FLaborFlatCost write FLaborFlatCost;
property LaborQuantity: Double read FLaborQuantity write FLaborQuantity;
property LaborUnitCost: Double read FLaborUnitCost write FLaborUnitCost;
property MillesimeId: Integer read FMillesimeId write FMillesimeId;
property Nomenclature: string read FNomenclature write FNomenclature;
property SellingPrice: Double read FSellingPrice write FSellingPrice;
property &Unit: TUnit read FUnit;
public
constructor Create; override;
destructor Destroy; override;
end;
TRoot = class(TJsonDTO)
private
FCustomerProjectId: string;
FOk: Boolean;
[JSONName('ouvrages'), JSONMarshalled(False)]
FOuvragesArray: TArray;
[GenericListReflect]
FOuvrages: TObjectList;
function GetOuvrages: TObjectList;
protected
function GetAsJson: string; override;
published
property CustomerProjectId: string read FCustomerProjectId write FCustomerProjectId;
property Ok: Boolean read FOk write FOk;
property Ouvrages: TObjectList read GetOuvrages;
public
destructor Destroy; override;
end;
implementation
{ TElements }
constructor TElements.Create;
begin
inherited;
FUnit := TUnit.Create;
end;
destructor TElements.Destroy;
begin
FUnit.Free;
GetElements.Free;
inherited;
end;
function TElements.GetElements: TObjectList;
begin
Result := ObjectList(FElements, FElementsArray);
end;
function TElements.GetAsJson: string;
begin
RefreshArray(FElements, FElementsArray);
Result := inherited;
end;
{ TOuvrages }
constructor TOuvrages.Create;
begin
inherited;
FUnit := TUnit.Create;
end;
destructor TOuvrages.Destroy;
begin
FUnit.Free;
GetElements.Free;
inherited;
end;
function TOuvrages.GetElements: TObjectList;
begin
Result := ObjectList(FElements, FElementsArray);
end;
function TOuvrages.GetAsJson: string;
begin
RefreshArray(FElements, FElementsArray);
Result := inherited;
end;
{ TRoot }
destructor TRoot.Destroy;
begin
GetOuvrages.Free;
inherited;
end;
function TRoot.GetOuvrages: TObjectList;
begin
Result := ObjectList(FOuvrages, FOuvragesArray);
end;
function TRoot.GetAsJson: string;
begin
RefreshArray(FOuvrages, FOuvragesArray);
Result := inherited;
end;
end.