I would like to create a component with the structure as bellow:
type
TCustomMyComp = class;
TMyComp = class;
TCustomSqlCommands = class;
TSqlCommands = class;
TFields = class;
TFieldsItem = class;
TFieldsSqlCommands = class;
TCustomMyComp = class(TComponent)
private
FFields: TFields;
FSqlCommands: TSqlCommands;
procedure SetFields(Value: TFields);
procedure SetSqlCommands(Value: TSqlCommands);
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Fields: TFields read FFields write SetFields;
property SqlCommands: TSqlCommands read FSqlCommands write SetSqlCommands;
end;
TCustomSqlCommands = class(TPersistent)
private
FOwner: TCustomMyComp;
FSelect: TStrings;
FInsert: TStrings;
FUpdate: TStrings;
FDelete: TStrings;
procedure SetSql(Index: Integer; Value: TStrings);
public
constructor Create(AOwner: TCustomMyComp); virtual;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
published
property Select: TStrings index 0 read FSelect write SetSql;
property Insert: TStrings index 1 read FInsert write SetSql;
property Update: TStrings index 2 read FUpdate write SetSql;
property Delete: TStrings index 3 read FDelete write SetSql;
end;
[ComponentPlatformsAttribute(pidWin32 or pidWin64)]
TMyComp = class(TCustomMyComp)
published
property Fields;
property SqlCommands;
end;
TSqlCommands = class(TCustomSqlCommands)
published
property Insert;
property Update;
property Delete;
end;
//------- Fields -----------
TFields = class(TCollection)
private
FOwner: TCustomMyComp;
function GetItem(Index: Integer): TFieldsItem;
procedure SetItem(Index: Integer; Value: TFieldsItem);
protected
function GetOwner: TPersistent; override;
procedure Update(Item: TCollectionItem); override;
public
constructor Create(AOwner: TCustomMyComp);
function Add: TFieldsItem;
function Owner: TCustomMyComp;
end;
TFieldsItem = class(TCollectionItem)
private
FOwner: TCustomMyComp;
FSqlCommands: TFieldsSqlCommands;
procedure SetSqlCommands(Value: TFieldsSqlCommands);
protected
function GetDisplayName: String; override;
procedure SetIndex(Value: Integer); override;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
published
property SqlCommands: TFieldsSqlCommands read FSqlCommands write SetSqlCommands;
end;
TFieldsSqlCommands = class(TCustomSqlCommands)
published
property Select;
property Insert;
end;
I face 2 issues:
Property
SqlCommands: TSqlCommands
contain all properties that were defined underTCustomSqlCommands
even I defined to published onlyInsert,Update,Delete
.Property
Fileds->SqlCommands: TFieldsSqlCommands
contain NO properties even I defined to published onlySelect,Insert
.
What am I doing wrong?