Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 18-07-2011
Paulao Paulao is offline
Miembro
 
Registrado: sep 2003
Ubicación: Rua D 31 Casa 1 - Inhoaíba - Rio de Janeiro - RJ - Brasil
Posts: 637
Poder: 21
Paulao Va por buen camino
Error de Incompatibles Types

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.
Responder Con Cita
  #2  
Antiguo 18-07-2011
Paulao Paulao is offline
Miembro
 
Registrado: sep 2003
Ubicación: Rua D 31 Casa 1 - Inhoaíba - Rio de Janeiro - RJ - Brasil
Posts: 637
Poder: 21
Paulao Va por buen camino
Olvide una cosa. El error estas en esta linea:
Código:
procedure TListValidator.Validate(Documento: IDocument);
var
  IntNum: integer;
begin
  for intNum := 0 to Self.Count - 1 do
  begin
    try
      Self[intNum].Validate(Documento);//El error estas aca
    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;
Responder Con Cita
  #3  
Antiguo 18-07-2011
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.040
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Código Delphi [-]
Self[intNum].Validate(Documento);//El error estas aca

Y ahí qué representa 'Self' ?
Porque si es el formulario, self[] no es válido, por eso te sale el error.
Responder Con Cita
  #4  
Antiguo 18-07-2011
Paulao Paulao is offline
Miembro
 
Registrado: sep 2003
Ubicación: Rua D 31 Casa 1 - Inhoaíba - Rio de Janeiro - RJ - Brasil
Posts: 637
Poder: 21
Paulao Va por buen camino
No se que es, pero he visto una cosa aqui. Esta procedure pide IDocument, pero en su declaracion estas TDocumentoNovo. Cambie e ahora estas aparecendo otros errores, tambiém en la misma forma. Estoy cambiando para ver si funciona.
Responder Con Cita
  #5  
Antiguo 18-07-2011
Paulao Paulao is offline
Miembro
 
Registrado: sep 2003
Ubicación: Rua D 31 Casa 1 - Inhoaíba - Rio de Janeiro - RJ - Brasil
Posts: 637
Poder: 21
Paulao Va por buen camino
Que pasa es que esta procedure es Overload, entonces, mismo que la declaracion fuera TDocumentoNovo y en la llamada for IDocument, no deveria dar este problema, pues es Overload. Que puede ser esto?
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Error Incompatible types kavernikola Varios 3 04-01-2011 17:13:29
Sentencia Case... error Incompatible types BlueSteel Varios 5 05-10-2010 21:53:30
Error Types.Dcu juan_inf Varios 1 21-05-2010 15:34:18
Error: Incompatible types: got "Pointer" expected elarys OOP 2 06-03-2010 00:53:12
Error de tipos incompatibles jorgegetafe Varios 2 03-10-2007 00:12:08


La franja horaria es GMT +2. Ahora son las 06:29:10.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi