CONVERSAO INTERFACE VB.NET PARA C#

TUNUSAT 11/03/2014 10:08:32
#435818
Por favor, pessoALL,

Estou usando aqueles sites de conversão... exemplo:
http://www.carlosag.net/tools/codetranslator/
... mas eles não estão conseguindo converter o trecho abaixo:

Quero passar de VB.Net:


Public Interface ICrud(Of T, tipoChave)
Sub Alterar(ByVal entidade As T)
Sub Excluir(ByVal chave As tipoChave)
Function Inserir(ByVal entidade As T) As tipoChave
Function SelecionarPorChave(ByVal chave As tipoChave) As T
Function SelecionarTodos() As List(Of T)
Function SelecionarPorParametro(ByVal entidade As T) As List(Of T)
End Interface


Para C#.Net no conversor:


public interface ICrud {
void Alterar(T entidade);
void Excluir(tipoChave chave);
tipoChave Inserir(T entidade);
T SelecionarPorChave(tipoChave chave);
List[] SelecionarTodos();
List[] SelecionarPorParametro(T entidade);
}


Melhorando... mas ainda tem alguns erros!


interface ICrud
{
public interface ICrud
{
//public MustOverride Sub Alterar(ByVal entidade As T)
//void Alterar(T entidade);
abstract public void Alterar<T>(out T entidade);

//public MustOverride Sub Excluir(ByVal chave As tipoChave)
//void Excluir(tipoChave chave);
abstract public void Excluir<T>(out T tipoChave);

//public MustOverride Function Inserir(ByVal entidade As T) As tipoChave
//tipoChave Inserir(T entidade);
abstract public tipoChave Inserir<T>(out T entidade);

//public MustOverride Function SelecionarPorChave(ByVal chave As tipoChave) As T
//T SelecionarPorChave(tipoChave chave);
abstract public SelecionarPorChave<T>(tipoChave);

//public MustOverride Function SelecionarTodos() As List(Of T)
//List[] SelecionarTodos();
abstract public List<T> SelecionarTodos();

//public MustOverride Function SelecionarPorParametro(ByVal entidade As T) As List(Of T)
//List[] SelecionarPorParametro(T entidade);
abstract public List<T> SelecionarPorParametro<T>(out T entidade);
}
}



Por favor, podem me ajudar a converter este trecho de código?


Obrigado,
Tunusat.
OCELOT 11/03/2014 11:46:18
#435825
A primeira estava quase correta
public interface ICrud<T, tipoChave> {
void Alterar(T entidade);
void Excluir(tipoChave chave);
tipoChave Inserir(T entidade);
T SelecionarPorChave(tipoChave chave);
List<T> SelecionarTodos();
List<T> SelecionarPorParametro(T entidade);
}


Aparentemente este conversor não entende muito bem de generics
OMAR2011 11/03/2014 13:29:06
#435841
Resposta escolhida
No site do macoratti tem isso.
http://www.macoratti.net/11/11/ConversorCodigo2011.zip
TUNUSAT 11/03/2014 16:27:43
#435857
Ocelot e Omar2011,

O conversor do Macoratti é o bicho.
O código ficou idêntico ao primeiro... mas acho que eu estava colocando em uma posição errada e então estava apresentando erro. Acho que é isto mesmo ... vou tentar com outro código para ver como vai ficar.


using System.Collections.Generic;



public interface ICrud<T, tipoChave>
{
void Alterar(T entidade);
void Excluir(tipoChave chave);
tipoChave Inserir(T entidade);
T SelecionarPorChave(tipoChave chave);
List<T> SelecionarTodos();
List<T> SelecionarPorParametro(T entidade);
}


Obrigado,
Tunusat.
Tópico encerrado , respostas não são mais permitidas