Ver Mensaje Individual
  #3  
Antiguo 17-10-2019
bucanero bucanero is offline
Miembro
 
Registrado: nov 2013
Ubicación: Almería, España
Posts: 208
Reputación: 13
bucanero Va camino a la fama
hola

Aqui propongo otras alternativas valida para las versiones modernas de delphi, y es utilizar directamente las funciones de la RTTI

- Forma 1:
Código Delphi [-]
uses  System.Rtti;

/// ...

function MethodAsString(const Method: TIdSSLVersion): String;
begin
  Result := TRttiEnumerationType.GetName(Method);
end;

function StrToMethod(const MethodName: string):TIdSSLVersion;
begin
  result := TRttiEnumerationType.GetValue(MethodName);
end;

-Forma 2:
Código Delphi [-]
uses System.TypInfo;

function MethodAsString(const Method: TIdSSLVersion): String;
begin
  result := GetENumName(TypeInfo(TIdSSLVersion), Ord(Method));
end;

function StrToMethod(const MethodName: string):TIdSSLVersion;
var
  value:integer;
begin
  value := GetEnumValue(TypeInfo(TIdSSLVersion), MethodName);
  result := TIdSSLVersion(value);
end;


Y forma de utilizarlo:

Código Delphi [-]
var
  Method: string;
begin
  Method := q_Correo.fieldByname('Method').asstring;
  with IdSSLIOHandlerSocketOpenSSL1 do begin
    SSLOptions.Method := StrToMethod(Method);  
    // ...
    MessageDlg(format('seleccionado %s ', [MethodAsString(SSLOptions.Method)]), mtInformation, [mbOK], 0);
  end;
Responder Con Cita