PAGUE 6 MESES
LEVE 12 MESES
GARANTIR DESCONTO

Fórum rtti - typecast #499158

26/10/2014

0

estou fazendo alguns testes para montar um framework...
a rotina abaixo esta funcionando corretamente...

class function TGenericDAO.GetTableName<T>(Obj: T): String;
var
Contexto: TRttiContext;
TypObj: TRttiType;
Atributo: TCustomAttribute;
begin
Contexto := TRttiContext.Create;
TypObj := Contexto.GetType(TObject(Obj).ClassInfo);
for Atributo in TypObj.GetAttributes do
begin
if Atributo is TableName then
Exit(TableName(Atributo).Name);
end;
end;

ocorre que tenho uma outra rotina que é identica a essa, mudando apenas o nome da funcao e o bloco do if...
essa outra funcao seria...
class function TGenericDAO.GetGeneratorName<T>(Obj: T): String;
e mudaria o if...
if Atributo is GeneratorName then
Exit(GeneratoName(Atributo).Name);

gostaria de saber, tentei, mas ainda nao consegui...
se tem como passar esse if como parametro, generics, metodo anonimo...

nao quero colocar um else...
e nem um in..


valeu
Felipe Barros

Felipe Barros

Responder

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar