2017-03-01 21:40:57 +01:00
|
|
|
|
// ***************************************************************************
|
|
|
|
|
//
|
|
|
|
|
// Delphi MVC Framework
|
|
|
|
|
//
|
2020-01-06 16:49:18 +01:00
|
|
|
|
// Copyright (c) 2010-2020 Daniele Teti and the DMVCFramework Team
|
2017-03-01 21:40:57 +01:00
|
|
|
|
//
|
|
|
|
|
// https://github.com/danieleteti/delphimvcframework
|
|
|
|
|
//
|
|
|
|
|
// Collaborators with this file: Ezequiel Juliano M<>ller (ezequieljuliano@gmail.com)
|
|
|
|
|
//
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
//
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
|
|
unit MVCFramework.Tests.Serializer.Entities;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
System.SysUtils,
|
|
|
|
|
System.Classes,
|
|
|
|
|
System.Rtti,
|
|
|
|
|
System.Generics.Collections,
|
|
|
|
|
MVCFramework.Serializer.Commons;
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
|
|
TRole = (roAdmin, roGuest);
|
|
|
|
|
|
|
|
|
|
TNote = class
|
|
|
|
|
private
|
|
|
|
|
FDescription: string;
|
|
|
|
|
public
|
|
|
|
|
constructor Create(const ADescription: string);
|
|
|
|
|
property Description: string read FDescription write FDescription;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
TDepartment = class
|
|
|
|
|
private
|
|
|
|
|
FId: Int64;
|
|
|
|
|
FName: string;
|
|
|
|
|
|
|
|
|
|
// The MVCListOfAttribute attribute can be placed in Field or Property
|
2019-11-03 16:16:35 +01:00
|
|
|
|
//[MVCListOf(TNote)]
|
2017-03-01 21:40:57 +01:00
|
|
|
|
FNotes: TObjectList<TNote>;
|
|
|
|
|
public
|
|
|
|
|
constructor Create;
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
|
|
|
|
property Id: Int64 read FId write FId;
|
2018-10-14 18:23:20 +02:00
|
|
|
|
[MVCNameAs('Name')]
|
|
|
|
|
property name: string read FName write FName;
|
2017-03-01 21:40:57 +01:00
|
|
|
|
|
2019-11-03 16:16:35 +01:00
|
|
|
|
// [MVCListOf(TNote)]
|
2017-03-01 21:40:57 +01:00
|
|
|
|
property Notes: TObjectList<TNote> read FNotes write FNotes;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
TEntity = class
|
|
|
|
|
private
|
|
|
|
|
FId: Int64;
|
|
|
|
|
FCode: Integer;
|
|
|
|
|
FName: string;
|
|
|
|
|
FSalary: Double;
|
|
|
|
|
FBirthday: TDate;
|
|
|
|
|
FAccessDateTime: TDateTime;
|
|
|
|
|
FAccessTime: TTime;
|
|
|
|
|
FActive: Boolean;
|
|
|
|
|
FRole: TRole;
|
|
|
|
|
FTeporization: TTimeStamp;
|
|
|
|
|
FDepartment: TDepartment;
|
|
|
|
|
FDepartmentNull: TDepartment;
|
|
|
|
|
|
2019-11-03 16:16:35 +01:00
|
|
|
|
// [MVCListOf(TNote)]
|
2017-03-01 21:40:57 +01:00
|
|
|
|
FNotes: TObjectList<TNote>;
|
|
|
|
|
|
2019-11-03 16:16:35 +01:00
|
|
|
|
// [MVCListOf(TNote)]
|
2017-03-01 21:40:57 +01:00
|
|
|
|
FNotesEmpty: TObjectList<TNote>;
|
|
|
|
|
|
|
|
|
|
// The MVCValueAsTypeAttribute attribute can be placed in Field or Property
|
|
|
|
|
[MVCValueAsType(System.TypeInfo(string))]
|
|
|
|
|
FAppreciationAs: TValue;
|
|
|
|
|
|
|
|
|
|
FAppreciation: TValue;
|
|
|
|
|
|
|
|
|
|
FIgnored: string;
|
|
|
|
|
|
|
|
|
|
// The MVCDoNotSerializeAttribute attribute can be placed in Field or Property
|
|
|
|
|
[MVCDoNotSerialize]
|
|
|
|
|
FTransient: string;
|
|
|
|
|
public
|
|
|
|
|
constructor Create;
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
|
|
|
|
property Id: Int64 read FId write FId;
|
|
|
|
|
property Code: Integer read FCode write FCode;
|
2018-10-14 18:23:20 +02:00
|
|
|
|
[MVCNameAs('Name')]
|
|
|
|
|
property name: string read FName write FName;
|
2017-03-01 21:40:57 +01:00
|
|
|
|
property Salary: Double read FSalary write FSalary;
|
|
|
|
|
property Birthday: TDate read FBirthday write FBirthday;
|
|
|
|
|
property AccessDateTime: TDateTime read FAccessDateTime write FAccessDateTime;
|
|
|
|
|
property AccessTime: TTime read FAccessTime write FAccessTime;
|
|
|
|
|
property Active: Boolean read FActive write FActive;
|
|
|
|
|
property Role: TRole read FRole write FRole;
|
|
|
|
|
property Teporization: TTimeStamp read FTeporization write FTeporization;
|
|
|
|
|
property Department: TDepartment read FDepartment write FDepartment;
|
|
|
|
|
property DepartmentNull: TDepartment read FDepartmentNull write FDepartmentNull;
|
|
|
|
|
|
2019-11-03 16:16:35 +01:00
|
|
|
|
//[MVCListOf(TNote)]
|
2017-03-01 21:40:57 +01:00
|
|
|
|
property Notes: TObjectList<TNote> read FNotes;
|
|
|
|
|
|
2019-11-03 16:16:35 +01:00
|
|
|
|
//[MVCListOf(TNote)]
|
2017-03-01 21:40:57 +01:00
|
|
|
|
property NotesEmpty: TObjectList<TNote> read FNotesEmpty;
|
|
|
|
|
|
|
|
|
|
[MVCValueAsType(System.TypeInfo(string))]
|
|
|
|
|
property AppreciationAs: TValue read FAppreciationAs write FAppreciationAs;
|
|
|
|
|
|
|
|
|
|
property Appreciation: TValue read FAppreciation write FAppreciation;
|
2018-10-14 18:23:20 +02:00
|
|
|
|
property Ignored: string read FIgnored write FIgnored;
|
2017-03-01 21:40:57 +01:00
|
|
|
|
|
|
|
|
|
[MVCDoNotSerialize]
|
|
|
|
|
property Transient: string read FTransient write FTransient;
|
|
|
|
|
end;
|
|
|
|
|
|
2017-03-28 14:52:13 +02:00
|
|
|
|
[MVCNameCase(ncUpperCase)]
|
2017-03-01 21:40:57 +01:00
|
|
|
|
TEntityUpperCase = class
|
|
|
|
|
private
|
|
|
|
|
FId: Int64;
|
|
|
|
|
FCode: Integer;
|
|
|
|
|
FName: string;
|
|
|
|
|
public
|
|
|
|
|
property Id: Int64 read FId write FId;
|
|
|
|
|
property Code: Integer read FCode write FCode;
|
2018-10-14 18:23:20 +02:00
|
|
|
|
property name: string read FName write FName;
|
2017-03-01 21:40:57 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2017-03-28 14:52:13 +02:00
|
|
|
|
[MVCNameCase(ncLowerCase)]
|
2017-03-01 21:40:57 +01:00
|
|
|
|
TEntityLowerCase = class
|
|
|
|
|
private
|
|
|
|
|
FId: Int64;
|
|
|
|
|
FCode: Integer;
|
|
|
|
|
FName: string;
|
|
|
|
|
public
|
|
|
|
|
property Id: Int64 read FId write FId;
|
|
|
|
|
property Code: Integer read FCode write FCode;
|
2018-10-14 18:23:20 +02:00
|
|
|
|
property name: string read FName write FName;
|
2017-03-01 21:40:57 +01:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
// The MVCNameAsAttribute attribute can be placed in Field or Property
|
|
|
|
|
TEntityNameAs = class
|
|
|
|
|
private
|
|
|
|
|
[MVCNameAs('Id_Id')]
|
|
|
|
|
FId: Int64;
|
|
|
|
|
|
|
|
|
|
[MVCNameAs('Code_Code')]
|
|
|
|
|
FCode: Integer;
|
|
|
|
|
|
|
|
|
|
[MVCNameAs('Name_Name')]
|
|
|
|
|
FName: string;
|
|
|
|
|
public
|
|
|
|
|
[MVCNameAs('Id_Id')]
|
|
|
|
|
property Id: Int64 read FId write FId;
|
|
|
|
|
|
|
|
|
|
[MVCNameAs('Code_Code')]
|
|
|
|
|
property Code: Integer read FCode write FCode;
|
|
|
|
|
|
|
|
|
|
[MVCNameAs('Name_Name')]
|
2018-10-14 18:23:20 +02:00
|
|
|
|
property name: string read FName write FName;
|
2017-03-01 21:40:57 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2018-10-14 18:23:20 +02:00
|
|
|
|
TMVCNullable<T> = record
|
|
|
|
|
private
|
|
|
|
|
fValue: T;
|
|
|
|
|
fHasValue: Boolean;
|
|
|
|
|
function GetHasValue: Boolean; inline;
|
|
|
|
|
procedure SetValue(const Value: T);
|
|
|
|
|
public
|
|
|
|
|
procedure Clear;
|
|
|
|
|
property HasValue: Boolean read GetHasValue;
|
|
|
|
|
property Value: T read fValue write SetValue;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
TMVCNullableInteger = TMVCNullable<Integer>;
|
|
|
|
|
TMVCNullableString = TMVCNullable<string>;
|
|
|
|
|
|
2017-03-01 21:40:57 +01:00
|
|
|
|
TEntityCustom = class
|
|
|
|
|
private
|
|
|
|
|
FId: Int64;
|
|
|
|
|
FCode: Integer;
|
|
|
|
|
FName: string;
|
|
|
|
|
public
|
|
|
|
|
property Id: Int64 read FId write FId;
|
|
|
|
|
property Code: Integer read FCode write FCode;
|
2018-10-14 18:23:20 +02:00
|
|
|
|
[MVCNameAs('Name')]
|
|
|
|
|
property name: string read FName write FName;
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
TEntityCustomWithNullables = class(TEntityCustom)
|
|
|
|
|
private
|
|
|
|
|
FNullableInteger: TMVCNullable<Integer>;
|
2018-10-31 01:07:23 +01:00
|
|
|
|
FNullableString: TMVCNullable<string>;
|
2018-10-14 18:23:20 +02:00
|
|
|
|
public
|
|
|
|
|
property NullableInteger: TMVCNullable<Integer> read FNullableInteger write FNullableInteger;
|
2018-10-31 01:07:23 +01:00
|
|
|
|
property NullableString: TMVCNullable<string> read FNullableString write FNullableString;
|
2017-03-01 21:40:57 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2019-06-26 19:31:53 +02:00
|
|
|
|
TEntityCustomWithGuid = class(TEntityCustom)
|
|
|
|
|
private
|
|
|
|
|
FGuidValue: TGUID;
|
|
|
|
|
public
|
|
|
|
|
property GuidValue: TGUID read FGuidValue write FGuidValue;
|
|
|
|
|
end;
|
|
|
|
|
|
2017-07-12 01:02:23 +02:00
|
|
|
|
TColorEnum = (RED, GREEN, BLUE);
|
2019-08-12 22:27:36 +02:00
|
|
|
|
TMonthEnum = (meJanuary, meFebruary, meMarch, meApril);
|
2017-07-12 01:02:23 +02:00
|
|
|
|
|
|
|
|
|
TEntityWithEnums = class
|
|
|
|
|
private
|
|
|
|
|
FId: Int64;
|
|
|
|
|
FCode: Integer;
|
|
|
|
|
FName: string;
|
|
|
|
|
FColor: TColorEnum;
|
2019-08-12 22:27:36 +02:00
|
|
|
|
FMonthName: TMonthEnum;
|
|
|
|
|
FMonthOrder: TMonthEnum;
|
2020-03-12 18:24:20 +01:00
|
|
|
|
FMonthName2: TMonthEnum;
|
2017-07-12 01:02:23 +02:00
|
|
|
|
public
|
|
|
|
|
property Id: Int64 read FId write FId;
|
|
|
|
|
property Code: Integer read FCode write FCode;
|
2018-10-31 01:07:23 +01:00
|
|
|
|
[MVCNameAs('Name')]
|
2018-10-14 18:23:20 +02:00
|
|
|
|
property name: string read FName write FName;
|
2017-07-12 01:02:23 +02:00
|
|
|
|
property Color: TColorEnum read FColor write FColor;
|
2020-03-12 20:37:48 +01:00
|
|
|
|
[MVCEnumSerialization(estEnumMappedValues, 'January,February,March,April')]
|
2019-08-12 22:27:36 +02:00
|
|
|
|
property MonthName: TMonthEnum read FMonthName write FMonthName;
|
2020-03-12 20:37:48 +01:00
|
|
|
|
[MVCEnumSerialization(estEnumName)]
|
2020-03-12 18:24:20 +01:00
|
|
|
|
property MonthName2: TMonthEnum read FMonthName2 write FMonthName2;
|
2020-03-12 20:37:48 +01:00
|
|
|
|
[MVCEnumSerialization(estEnumOrd)]
|
2019-08-12 22:27:36 +02:00
|
|
|
|
property MonthOrder: TMonthEnum read FMonthOrder write FMonthOrder;
|
2017-07-12 01:02:23 +02:00
|
|
|
|
end;
|
|
|
|
|
|
2017-03-28 14:52:13 +02:00
|
|
|
|
[MVCSerialize(stFields)]
|
|
|
|
|
TEntitySerializeFields = class
|
|
|
|
|
private
|
|
|
|
|
FId: Int64;
|
|
|
|
|
FCode: Integer;
|
|
|
|
|
FName: string;
|
|
|
|
|
public
|
|
|
|
|
property Id: Int64 read FId write FId;
|
|
|
|
|
property Code: Integer read FCode write FCode;
|
2018-10-14 18:23:20 +02:00
|
|
|
|
property name: string read FName write FName;
|
2017-03-28 14:52:13 +02:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
[MVCSerialize(stProperties)]
|
|
|
|
|
TEntitySerializeProperties = class
|
|
|
|
|
private
|
|
|
|
|
FId: Int64;
|
|
|
|
|
FCode: Integer;
|
|
|
|
|
FName: string;
|
|
|
|
|
public
|
|
|
|
|
property Id: Int64 read FId write FId;
|
|
|
|
|
property Code: Integer read FCode write FCode;
|
2018-10-31 01:07:23 +01:00
|
|
|
|
[MVCNameAs('Name')]
|
2018-10-14 18:23:20 +02:00
|
|
|
|
property name: string read FName write FName;
|
2017-03-28 14:52:13 +02:00
|
|
|
|
end;
|
|
|
|
|
|
2017-03-01 21:40:57 +01:00
|
|
|
|
TSale = class
|
|
|
|
|
private
|
|
|
|
|
FEntity: TEntityCustom;
|
|
|
|
|
FNotes: TStringStream;
|
|
|
|
|
FNotesAsString: TStringStream;
|
|
|
|
|
public
|
|
|
|
|
constructor Create;
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
|
|
|
|
property Entity: TEntityCustom read FEntity write FEntity;
|
|
|
|
|
property Notes: TStringStream read FNotes write FNotes;
|
|
|
|
|
|
|
|
|
|
[MVCSerializeAsString]
|
|
|
|
|
property NotesAsString: TStringStream read FNotesAsString write FNotesAsString;
|
|
|
|
|
end;
|
|
|
|
|
|
2019-05-17 16:15:18 +02:00
|
|
|
|
TEntityWithArray = class
|
|
|
|
|
private
|
|
|
|
|
FId: Int64;
|
|
|
|
|
FNames: TArray<String>;
|
|
|
|
|
FValues: TArray<Integer>;
|
|
|
|
|
public
|
|
|
|
|
property Id: Int64 read FId write FId;
|
|
|
|
|
property Names: TArray<String> read FNames write FNames;
|
|
|
|
|
property Values: TArray<Integer> read FValues write FValues;
|
|
|
|
|
end;
|
|
|
|
|
|
2019-09-18 13:30:50 +02:00
|
|
|
|
IChildEntity = interface
|
|
|
|
|
['{4A4CF508-D64F-4205-9783-E91B888A8987}']
|
|
|
|
|
function GetCode: Integer;
|
|
|
|
|
procedure SetCode(const Value: Integer);
|
|
|
|
|
function GetDescription: string;
|
|
|
|
|
procedure SetDescription(const Value: string);
|
|
|
|
|
|
|
|
|
|
property Code: Integer read GetCode write SetCode;
|
|
|
|
|
property Description: string read GetDescription write SetDescription;
|
|
|
|
|
end;
|
|
|
|
|
|
2019-09-18 01:14:54 +02:00
|
|
|
|
IEntityWithInterface = interface
|
|
|
|
|
['{81B1323F-B3FF-4FBD-84F3-9BDBA9997D8E}']
|
|
|
|
|
function GetId: Integer;
|
|
|
|
|
procedure SetId(const Value: Integer);
|
|
|
|
|
function GetName: string;
|
|
|
|
|
procedure SetName(const Value: string);
|
2019-09-18 13:30:50 +02:00
|
|
|
|
function GetChildEntity: IChildEntity;
|
|
|
|
|
procedure SetChildEntity(const Value: IChildEntity);
|
2019-09-18 01:14:54 +02:00
|
|
|
|
|
|
|
|
|
property Id: Integer read GetId write SetId;
|
|
|
|
|
property Name: string read GetName write SetName;
|
2019-09-18 13:30:50 +02:00
|
|
|
|
property ChildEntity: IChildEntity read GetChildEntity write SetChildEntity;
|
2019-09-18 01:14:54 +02:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
TEntityWithInterface = class(TInterfacedObject, IEntityWithInterface)
|
|
|
|
|
private
|
|
|
|
|
FId: Integer;
|
|
|
|
|
FName: string;
|
2019-09-18 13:30:50 +02:00
|
|
|
|
FChildEntity: IChildEntity;
|
2019-09-18 01:14:54 +02:00
|
|
|
|
function GetId: Integer;
|
|
|
|
|
procedure SetId(const Value: Integer);
|
|
|
|
|
function GetName: string;
|
|
|
|
|
procedure SetName(const Value: string);
|
2019-09-18 13:30:50 +02:00
|
|
|
|
function GetChildEntity: IChildEntity;
|
|
|
|
|
procedure SetChildEntity(const Value: IChildEntity);
|
2019-09-18 01:14:54 +02:00
|
|
|
|
public
|
2019-09-18 13:30:50 +02:00
|
|
|
|
constructor Create;
|
2019-09-18 01:14:54 +02:00
|
|
|
|
property Id: Integer read GetId write SetId;
|
|
|
|
|
property Name: string read GetName write SetName;
|
2019-09-18 13:30:50 +02:00
|
|
|
|
property ChildEntity: IChildEntity read GetChildEntity write SetChildEntity;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
TChildEntity = class(TInterfacedObject, IChildEntity)
|
|
|
|
|
private
|
|
|
|
|
FCode: Integer;
|
|
|
|
|
FDescription: string;
|
|
|
|
|
function GetCode: Integer;
|
|
|
|
|
procedure SetCode(const Value: Integer);
|
|
|
|
|
function GetDescription: string;
|
|
|
|
|
procedure SetDescription(const Value: string);
|
|
|
|
|
public
|
|
|
|
|
property Code: Integer read GetCode write SetCode;
|
|
|
|
|
property Description: string read GetDescription write SetDescription;
|
2019-09-18 01:14:54 +02:00
|
|
|
|
end;
|
|
|
|
|
|
2019-10-14 23:11:08 +02:00
|
|
|
|
TGenericEntity<T: class> = class
|
|
|
|
|
private
|
|
|
|
|
FCode: Integer;
|
|
|
|
|
FItems: TObjectList<T>;
|
|
|
|
|
FDescription: string;
|
|
|
|
|
public
|
|
|
|
|
constructor Create;
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
property Code: Integer read FCode write FCode;
|
|
|
|
|
property Description: string read FDescription write FDescription;
|
|
|
|
|
property Items: TObjectList<T> read FItems write FItems;
|
|
|
|
|
end;
|
|
|
|
|
|
2019-10-15 12:51:08 +02:00
|
|
|
|
TMultipleGenericEntity<T1: class; T2: class> = class
|
|
|
|
|
private
|
|
|
|
|
FCode: Integer;
|
|
|
|
|
FItems: TObjectList<T1>;
|
|
|
|
|
FItems2: TObjectList<T2>;
|
|
|
|
|
FDescription: string;
|
|
|
|
|
public
|
|
|
|
|
constructor Create;
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
property Code: Integer read FCode write FCode;
|
|
|
|
|
property Description: string read FDescription write FDescription;
|
|
|
|
|
property Items: TObjectList<T1> read FItems write FItems;
|
|
|
|
|
property Items2: TObjectList<T2> read FItems2 write FItems2;
|
|
|
|
|
end;
|
|
|
|
|
|
2019-09-18 01:14:54 +02:00
|
|
|
|
|
2017-03-01 21:40:57 +01:00
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ TEntity }
|
|
|
|
|
|
|
|
|
|
constructor TEntity.Create;
|
|
|
|
|
begin
|
|
|
|
|
inherited Create;
|
|
|
|
|
FDepartment := TDepartment.Create;
|
|
|
|
|
FNotes := TObjectList<TNote>.Create(True);
|
|
|
|
|
FNotesEmpty := TObjectList<TNote>.Create(True);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
destructor TEntity.Destroy;
|
|
|
|
|
begin
|
|
|
|
|
FDepartment.Free;
|
|
|
|
|
FNotes.Free;
|
|
|
|
|
FNotesEmpty.Free;
|
|
|
|
|
inherited Destroy;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
{ TDepartment }
|
|
|
|
|
|
|
|
|
|
constructor TDepartment.Create;
|
|
|
|
|
begin
|
|
|
|
|
FNotes := TObjectList<TNote>.Create(True);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
destructor TDepartment.Destroy;
|
|
|
|
|
begin
|
|
|
|
|
FNotes.Free;
|
|
|
|
|
inherited;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
{ TNote }
|
|
|
|
|
|
|
|
|
|
constructor TNote.Create(const ADescription: string);
|
|
|
|
|
begin
|
|
|
|
|
inherited Create;
|
|
|
|
|
FDescription := ADescription;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
{ TSale }
|
|
|
|
|
|
|
|
|
|
constructor TSale.Create;
|
|
|
|
|
begin
|
|
|
|
|
FEntity := TEntityCustom.Create;
|
|
|
|
|
FNotes := TStringStream.Create;
|
|
|
|
|
FNotesAsString := TStringStream.Create;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
destructor TSale.Destroy;
|
|
|
|
|
begin
|
|
|
|
|
FEntity.Free;
|
|
|
|
|
FNotes.Free;
|
|
|
|
|
FNotesAsString.Free;
|
|
|
|
|
inherited;
|
|
|
|
|
end;
|
|
|
|
|
|
2018-10-14 18:23:20 +02:00
|
|
|
|
{ TMVCNullable<T> }
|
|
|
|
|
|
|
|
|
|
procedure TMVCNullable<T>.Clear;
|
|
|
|
|
begin
|
|
|
|
|
fHasValue := False;
|
|
|
|
|
fValue := default (T);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TMVCNullable<T>.GetHasValue: Boolean;
|
|
|
|
|
begin
|
|
|
|
|
Result := fHasValue;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TMVCNullable<T>.SetValue(const Value: T);
|
|
|
|
|
begin
|
|
|
|
|
fValue := Value;
|
|
|
|
|
fHasValue := True;
|
|
|
|
|
end;
|
|
|
|
|
|
2019-09-18 01:14:54 +02:00
|
|
|
|
{ TEntityWithInterface }
|
|
|
|
|
|
2019-09-18 13:30:50 +02:00
|
|
|
|
constructor TEntityWithInterface.Create;
|
|
|
|
|
begin
|
|
|
|
|
FChildEntity := TChildEntity.Create;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TEntityWithInterface.GetChildEntity: IChildEntity;
|
|
|
|
|
begin
|
|
|
|
|
Result := FChildEntity;
|
|
|
|
|
end;
|
|
|
|
|
|
2019-09-18 01:14:54 +02:00
|
|
|
|
function TEntityWithInterface.GetId: Integer;
|
|
|
|
|
begin
|
|
|
|
|
Result := FId;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TEntityWithInterface.GetName: string;
|
|
|
|
|
begin
|
|
|
|
|
Result := FName;
|
|
|
|
|
end;
|
|
|
|
|
|
2019-09-18 13:30:50 +02:00
|
|
|
|
procedure TEntityWithInterface.SetChildEntity(const Value: IChildEntity);
|
|
|
|
|
begin
|
|
|
|
|
FChildEntity := Value;
|
|
|
|
|
end;
|
|
|
|
|
|
2019-09-18 01:14:54 +02:00
|
|
|
|
procedure TEntityWithInterface.SetId(const Value: Integer);
|
|
|
|
|
begin
|
|
|
|
|
FId := Value;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TEntityWithInterface.SetName(const Value: string);
|
|
|
|
|
begin
|
|
|
|
|
FName := Value;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
2019-09-18 13:30:50 +02:00
|
|
|
|
{ TChildEntity }
|
|
|
|
|
|
|
|
|
|
function TChildEntity.GetCode: Integer;
|
|
|
|
|
begin
|
|
|
|
|
Result := FCode;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TChildEntity.GetDescription: string;
|
|
|
|
|
begin
|
|
|
|
|
Result := FDescription;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TChildEntity.SetCode(const Value: Integer);
|
|
|
|
|
begin
|
|
|
|
|
FCode := Value;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TChildEntity.SetDescription(const Value: string);
|
|
|
|
|
begin
|
|
|
|
|
FDescription := Value;
|
|
|
|
|
end;
|
|
|
|
|
|
2019-10-14 23:11:08 +02:00
|
|
|
|
{ TGenericEntity<T> }
|
|
|
|
|
|
|
|
|
|
constructor TGenericEntity<T>.Create;
|
|
|
|
|
begin
|
|
|
|
|
inherited Create;
|
|
|
|
|
FItems := TObjectList<T>.Create;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
destructor TGenericEntity<T>.Destroy;
|
|
|
|
|
begin
|
|
|
|
|
FItems.Free;
|
|
|
|
|
inherited Destroy;
|
|
|
|
|
end;
|
|
|
|
|
|
2019-10-15 12:51:08 +02:00
|
|
|
|
constructor TMultipleGenericEntity<T1,T2>.Create;
|
|
|
|
|
begin
|
|
|
|
|
inherited Create;
|
|
|
|
|
FItems := TObjectList<T1>.Create;
|
|
|
|
|
FItems2 := TObjectList<T2>.Create;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
destructor TMultipleGenericEntity<T1,T2>.Destroy;
|
|
|
|
|
begin
|
|
|
|
|
FItems.Free;
|
|
|
|
|
FItems2.Free;
|
|
|
|
|
inherited Destroy;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
2017-03-01 21:40:57 +01:00
|
|
|
|
end.
|