Ah!! e tirei a mãe do cara da jogada, dessa vez deixo
passar ....rsrsrsrs.
Uma coisa que achei estranho como o Infra vai saber como relacionar
cliente e cidade se ele nao tem os campos de relacionamentos
explicitamente ?
unit u_ClienteModel;
interface
uses
InfraValueTypeIntf,
InfraValueType,
InfraCommonIntf,
u_ModelInterfaces;
type
TCliente = class(TInfraObject, ICliente)
private
FID:IInfraInteger;
FNome:IInfraString;
FNascimento:IInfraDate;
FTelefone:IInfraString;
FEndereco:IInfraString;
FAtivo:IInfraBoolean;
FCidade:ICidade;
protected
function GetID : IInfraInteger;
procedure SetID(const val : IInfraInteger);
function GetDataNascimento : IInfraDate;
procedure SetDataNascimento(const val : IInfraDate);
function GetTelefone : IInfraString;
procedure SetTelefone(const val : IInfraString);
function GetNome : IInfraString;
procedure SetNome(const val : IInfraString);
function GetEndereco : IInfraString;
procedure SetEndereco(const val : IInfraString);
function GetAtivo : IInfraBoolean;
procedure SetAtivo(const val : IInfraBoolean);
function GetCidade : ICidade;
procedure SetCidade(const val : ICidade);
{property's }
property ID : IInfraInteger read GetID write SetID;
property Nome : IInfraString read GetNome write
SetNome;
property Datanascimento : IInfraDate read
GetDatanascimento write SetDatanascimento;
property Telefone : IInfraString read GetTelefone
write SetTelefone;
property Cidade : ICidade read GetCidade write
SetCidade;
property Ativo : IInfraBoolean read GetAtivo write
SetAtivo;
property Endereco : IInfraString read GetEndereco
write SetEndereco;
public
procedure InfraInitInstance;override;
end;
function RegisterClienteOnReflection: IClassInfo;
implementation
procedure TCliente.InfraInitInstance;
begin
inherited;
FID := AddProperty('ID') as IInfraInteger;
FNascimento := AddProperty('Nascimento') as IInfraDate;
FNome := AddProperty('Nome') as IInfraString;
FTelefone := AddProperty('Telefone') as IInfraString;
FCidade := AddProperty('Cidade') as ICidade;
FAtivo := AddProperty('Ativo') as IInfraBoolean;
FEndereco := AddProperty('Endereco') as IInfraString;
end;
function TCliente.GetEndereco: IInfraString;
begin
Result:= FEndereco;
end;
function TCliente.GetID: IInfraInteger;
begin
Result:=FID;
end;
procedure TCliente.SetID(const val : IInfraInteger);
begin
Fid := val;
end;
function TCliente.GetAtivo: IInfraBoolean;
begin
Result:=FAtivo;
end;
function TCliente.GetCidade: ICidade;
begin
Result := FCidade;
end;
function TCliente.GetDataNascimento: IInfraDate;
begin
Result:= FNascimento;
end;
procedure TCliente.SetAtivo(const val: IInfraBoolean);
begin
FAtivo := val;
end;
procedure TCliente.SetCidade(const val: ICidade);
begin
FCidade := val;
end;
procedure TCliente.SetDataNascimento(const val :
IInfraDate);
begin
FNascimento:=val;
end;
procedure TCliente.SetEndereco(const val: IInfraString);
begin
FEndereco := val;
end;
function TCliente.GetTelefone: IInfraString;
begin
result:= FTelefone;
end;
procedure TCliente.SetTelefone(const val : IInfraString);
begin
FTelefone:=val;
end;
function TCliente.GetNome: IInfraString;
begin
Result := FNome;
end;
procedure TCliente.SetNome(const val : IInfraString);
begin
FNome := val;
end;
function RegisterClienteOnReflection: IClassInfo;
begin
with TypeService do
begin
with AddType(ICliente, 'Cliente', TCliente,
IInfraObject, GetType(IInfraObject)) do
begin
AddConstructorInfo('Create', nil, @TCliente.Create);
AddPropertyInfo('Id', GetType
(IInfraInteger),@TCliente.GetID,@TCliente.SetID);
AddPropertyInfo('Nome', GetType
(IInfraString),@TCliente.GetNome,@TCliente.SetNome);
AddPropertyInfo('DataNascimento', GetType
(IInfraDate),@TCliente.GetDataNascimento,@TCliente.SetDataNascimento);
AddPropertyInfo('Telefone', GetType
(IInfraString),@TCliente.GetTelefone,@TCliente.SetTelefone);
AddPropertyInfo('Endereco', GetType
(IInfraString),@TCliente.GetEndereco,@TCliente.SetEndereco);
AddPropertyInfo('Ativo', GetType
(IInfraBoolean),@TCliente.GetAtivo,@TCliente.SetAtivo);
AddPropertyInfo('Cidade', GetType
(ICidade),@TCliente.GetCidade,@TCliente.SetCidade);
end;
end;
end;
initialization
RegisterClienteOnReflection;
end.