Quando me voy a compilar mi proyecto, viene el error de: Incompatibles Types TDocumentoNovo y IDocument. Hoy es la primera vez que me voy a trabajar neste proyecto. Tengo dificultades de hacer algun tipo de debug para encuentrar errores. Abajo las dos Units onde estan los .pas que estan dando errores.
Código:
unit clsListValidator;
interface
uses
clsListPlugins, IValidatorUnit, IDocumentUnit;
Type
TListValidator = class(TObject)
private
FListValidator: TListPlugins;
FOnAfterValidate: TNotifyValidate;
FOnBeforeValidate: TNotifyValidate;
FOnErrorValidate: TOnErrorValidate;
function GetItems(Index: integer): IValidator;
procedure SetItems(Index: integer; const Value: IValidator);
procedure SetOnBeforeValidate(EventHandle: TNotifyValidate);
procedure SetonAfterValidate(EventHandle: TNotifyValidate);
procedure SetOnErrorValidate(EventHandle: TOnErrorValidate);
public
constructor Create;
destructor Destroy; override;
function Add(Validator: IValidator): Integer;
function Count: Integer;
procedure Delete(Index: integer); overload;
procedure Delete(GUID: string); overload;
procedure Clear;
procedure Validate(Documento: IDocument);
property Items[Index: integer]: IValidator read GetItems write SetItems;
default;
property OnErrorValidate: TOnErrorValidate read FOnErrorValidate write SetOnErrorValidate;
property OnBeforeValidate: TNotifyValidate read FOnBeforeValidate write SetOnBeforeValidate;
property OnAfterValidate: TNotifyValidate read FOnAfterValidate write SetOnAfterValidate;
end;
implementation
uses
SysUtils, Exceptions;
{ TListValidator }
{
******************************** TListValidator ********************************
}
constructor TListValidator.Create;
begin
FListValidator := TListPlugins.Create;
end;
destructor TListValidator.Destroy;
begin
FreeAndNil(FListValidator);
inherited;
end;
function TListValidator.Add(Validator: IValidator): Integer;
begin
Result := FListValidator.Add(Validator);
// Se houverem eventos de validações associados, associa a cada elemento inserido
if Assigned(Self.OnBeforeValidate) then
Validator.OnBeforeValidate := Self.OnBeforeValidate;
if Assigned(Self.OnAfterValidate) then
Validator.OnAfterValidate := Self.OnAfterValidate;
if Assigned(Self.OnErrorValidate) then
Validator.OnErrorValidate := Self.OnErrorValidate;
end;
function TListValidator.Count: Integer;
begin
Result := FListValidator.Count();
end;
procedure TListValidator.Delete(Index: integer);
begin
FListValidator.Delete(Index);
end;
procedure TListValidator.Delete(GUID: string);
begin
FListValidator.Delete(GUID);
end;
function TListValidator.GetItems(Index: integer): IValidator;
begin
Result := IValidator(FListValidator[Index]);
end;
procedure TListValidator.SetItems(Index: integer; const Value: IValidator);
begin
FListValidator[Index] := Value;
end;
procedure TListValidator.Validate(Documento: IDocument);
var
IntNum: integer;
begin
for intNum := 0 to Self.Count - 1 do
begin
try
Self[intNum].Validate(Documento);
except
On E:EPluginException do
Raise EPluginException.Create(E.ErrorCode, E.Message);
On E:Exception do
Raise Exception.Create(E.Message);
end; // Try..Except
end; // For
end;
procedure TListValidator.Clear;
begin
FListValidator.Clear;
end;
procedure TListValidator.SetOnAfterValidate(EventHandle: TNotifyValidate);
var
intNum: integer;
begin
FOnAfterValidate := EventHandle;
for intNum := 0 to Self.FListValidator.Count - 1 do
IValidator(Self.FListValidator[intNum]).OnAfterValidate := FOnAfterValidate;
end;
procedure TListValidator.SetOnBeforeValidate(
EventHandle: TNotifyValidate);
var
IntNum: integer;
begin
FOnBeforeValidate := EventHandle;
// Seta o evento de validação para todos os elementos da lista
for intNum := 0 to Self.FListValidator.Count - 1 do
IValidator(Self.FListValidator[intNum]).OnBeforeValidate := EventHandle;
end;
procedure TListValidator.SetOnErrorValidate(EventHandle: TOnErrorValidate);
var
intNum: integer;
begin
FOnErrorValidate := EventHandle;
for intNum := 0 to Self.FListValidator.Count - 1 do
IValidator(Self.FListValidator[intNum]).OnErrorValidate := FOnErrorValidate;
end;
end.
Mi Interface
Código:
unit IDocumentUnit;
interface
uses
Controls, IInterfaceBaseUnit, IListBaseUnit, ITipoDocumentoUnit, IDepartamentoUnit,
ICaixaUnit, IClienteUnit, ILocalUnit;
type
IDocument = interface(IInterfaceBase)
['{D48CBFA8-3292-44A2-89DD-BD7BA5823F6C}']
{ function GetComplemento: String;
function GetDataFinal: TDate;
function GetDataInicial: TDate;
function GetDescricao: String;
function GetSequencialFinal: Integer;
function GetSequencialInicial: Integer;
function GetCodTipoDocumento: Integer;
function GetCodDocumento: Integer;
function GetHasAutoComplete(): Boolean;
function GetAnomalias: IListBase;
function getValorIndices(): IListBase;
function getTipoDocumento(): ITipoDocumento;
function getQuantidadeDigitacao(): Integer;
procedure SetComplemento(const Value: String);
procedure SetDataFinal(Value: TDate);
procedure SetDataInicial(Value: TDate);
procedure SetDescricao(const Value: String);
procedure SetSequencialFinal(Value: Integer);
procedure SetSequencialInicial(Value: Integer);
procedure SetCodTipoDocumento(Value: Integer);
procedure SetCodDocumento(Value: Integer);
procedure SetHasAutoComplete(Value: Boolean);
procedure SetAnomalias(Value: IListBase);
procedure setTipoDocumento(const value: ITipoDocumento);
property TipoDocumento: ITipoDocumento read getTipoDocumento write setTipoDocumento;
property CodDocumento: Integer read GetCodDocumento write SetCodDocumento;
property Complemento: String read GetComplemento write SetComplemento;
property DataFinal: TDate read GetDataFinal write SetDataFinal;
property DataInicial: TDate read GetDataInicial write SetDataInicial;
property SequencialInicial: Integer read GetSequencialInicial write
SetSequencialInicial;
property SequencialFinal: Integer read GetSequencialFinal write
SetSequencialFinal;
property CodTipoDocumento: Integer read GetCodTipoDocumento write
SetCodTipoDocumento;
property Descricao: String read GetDescricao write SetDescricao;
property Anomalias: IListBase read GetAnomalias write SetAnomalias;
property HasAutoComplete: Boolean read GetHasAutoComplete write SetHasAutoComplete;
property ValorIndices: IListBase read getValorIndices;
}
function GetComplemento: String;
function GetDataFinal: TDate;
function GetDataInicial: TDate;
function GetDescricao: String;
function GetSequencialFinal: Integer;
function GetSequencialInicial: Integer;
function getQuantidadeDigitacao: Integer;
procedure SetCod_Caixa(Value: Integer);
procedure SetCod_Documento(Value: Integer);
procedure SetCod_Usuario(Value: Integer);
procedure SetComplemento(const Value: String);
procedure SetDataFinal(Value: TDate);
procedure SetDataInicial(Value: TDate);
procedure SetData_Digitacao(Value: TDate);
procedure SetDescricao(const Value: String);
procedure SetPrevisaoExpurgo(Value: TDate);
procedure SetSequencialFinal(Value: Integer);
procedure SetSequencialInicial(Value: Integer);
procedure SetCodTipoDocumento(Value: Integer);
function GetCodTipoDocumento: Integer;
function GetCodDocumento: Integer;
procedure SetCodDocumento(Value: Integer);
function GetHasAutoComplete: Boolean;
procedure SetHasAutoComplete(Value: Boolean);
function GetCliente: ICliente;
function GetDepartamento: IDepartamento;
function GetLocal: ILocal;
procedure SetCaixa(const Value: ICaixa);
function GetCaixa: ICaixa;
procedure SetAuditoria_Interna(const Value: String);
function GetAnomalias: IListBase;
procedure SetAnomalias(Value: IListBase);
function GetStatus: String;
procedure SetStatus(const Value: String);
function getValorIndices(): IListBase;
function getTipoDocumento: ITipoDocumento;
procedure setTipoDocumento(const value: ITipoDocumento);
procedure SetCod_Status(const Value: Integer);
function GetCod_Status: Integer;
function GetAuditoria_Interna: String;
function GetCod_Caixa: Integer;
function GetCod_Etiqueta: Integer;
function GetCod_Usuario: Integer;
function GetData_Digitacao: TDate;
function GetPrevisaoExpurgo: TDate;
procedure SetCod_Etiqueta(const Value: Integer);
function GetCod_xSolicitante: Integer;
procedure SetCod_xSolicitante(Value: Integer);
property Cliente: ICliente read GetCliente;
property Local: ILocal read GetLocal;
property Departamento: IDepartamento read GetDepartamento;
property TipoDocumento: ITipoDocumento read GetTipoDocumento write SetTipoDocumento;
property Caixa: ICaixa read GetCaixa write SetCaixa;
property Cod_Caixa: Integer read GetCod_Caixa write SetCod_Caixa;
property CodDocumento: Integer read GetCodDocumento write SetCod_Documento;
property Cod_Etiqueta: Integer read GetCod_Etiqueta write SetCod_Etiqueta;
property Cod_Usuario: Integer read GetCod_Usuario write SetCod_Usuario;
property Complemento: String read GetComplemento write SetComplemento;
property DataFinal: TDate read GetDataFinal write SetDataFinal;
property DataInicial: TDate read GetDataInicial write SetDataInicial;
property Data_Digitacao: TDate read GetData_Digitacao write SetData_Digitacao;
property Descricao: String read GetDescricao write SetDescricao;
property PrevisaoExpurgo: TDate read GetPrevisaoExpurgo write
SetPrevisaoExpurgo;
property SequencialFinal: Integer read GetSequencialFinal write
SetSequencialFinal;
property SequencialInicial: Integer read GetSequencialInicial write
SetSequencialInicial;
property CodTipoDocumento: Integer read GetCodTipoDocumento write SetCodTipoDocumento;
property HasAutoComplete: Boolean read GetHasAutoComplete write SetHasAutoComplete;
property Auditoria_Interna: String read GetAuditoria_Interna write SetAuditoria_Interna;
property Anomalias: IListBase read GetAnomalias write SetAnomalias;
property Status: String read GetStatus write SetStatus;
property ValorIndices: IListBase read GetValorIndices;
property Cod_Status: Integer read GetCod_Status write SetCod_Status;
property QuantidadeDigitacao: Integer read GetQuantidadeDigitacao;
property Cod_xSolicitante: Integer read GetCod_xSolicitante write SetCod_xSolicitante;
end;
implementation
end.