Skip to content

Instantly share code, notes, and snippets.

@jpolvora
Last active Jan 24, 2017
Embed
What would you like to do?
esqueminha pseudo java/C#
class ApiClient {
private string connectionString;
ctor(String connectionString) {
this.connectionString = connectionString;
}
public string FazAlgumaCoisa(string parametros) {
using (var conexao = new ConexaoComDb(connectionString)) {
return conexao.PegaDados(parametros);
}
}
}
class Business {
private ApiClient apiclient;
ctor(ApiClient apiclient) {
this.apiClient = apiclient;
}
public bool LeEImprime(string parametros) {
try {
//valida parâmetros
if (string.IsNullOrWhiteSpace(parametros)) return false;
var result = apiclient.FazAlgumaCoisa(parametros);
if (result != null) {
ChamaImpressora();
return true;
}
return false;
}
catch {
return false;
}
}
}
public class FormPrincipal {
private Business business;
ctor(Business business) {
this.business = business;
}
public void ButtonClickHandler(object sender, EventArgs args) {
var parametros = textBox1.Text;
var result = business.LeEImprime(parametros);
if (result == true) {
ShowMessage("Função executada com sucesso.");
}
}
}
class Program {
public static void main() {
var connectionString = LerConfiguration["ConnectionString"];
var apiclient = new ApiClient(connectionString);
var business = new Business(apiclient);
var formprincipal = new FormPrincipal(business);
formprincipal.Show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment