This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Cliente | |
{ | |
[Key] | |
public int Id { get; private set; } | |
public string Nome { get; private set; } | |
public string Sobrenome { get; private set; } | |
public DateTime DataNascimento { get; private set; } | |
public bool Ativo { get; private set; } | |
public Cliente(string nome, string sobrenome, DateTime dataNascimento, bool ativo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
var funilFactory = new FunilFactory(); | |
//Cadastra James como um Suspect | |
funilFactory.ObterFunil<Suspect>() | |
.Cadastrar(new FunilModel() { Nome = "James" }); | |
//Cadastra James como um Prospect | |
funilFactory.ObterFunil<Prospect>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FunilFactory : IFunilFactory | |
{ | |
public IFunil ObterFunil<T>() | |
{ | |
return (IFunil)Activator.CreateInstance(typeof(T)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IFunilFactory | |
{ | |
IFunil CriaFunil<T>(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace FactoryMethod | |
{ | |
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var suspect = Funil.Suspect; | |
var funilFactory = new FunilFactory(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace FactoryMethod | |
{ | |
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string funil = "suspect"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace FactoryMethod | |
{ | |
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var creators = new List<ICreator>() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.Write("Escolha a operação: (sum, sub, mult, div): "); | |
string operacao = Console.ReadLine(); | |
Console.Write("Digite o primeiro número: "); | |
int.TryParse(Console.ReadLine(), out int numero1); | |
Console.Write("Digite o segundo número: "); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CalculadoraStrategy | |
{ | |
public enum Operacao | |
{ | |
None, | |
Sum, | |
Sub, | |
Mult, | |
Div | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ContextStrategy<TResponse, TRequest, TSearch> | |
{ | |
private IStrategy<TResponse, TRequest> _strategy; | |
private readonly Dictionary<TSearch, IStrategy<TResponse, TRequest>> _dicStrategy = new Dictionary<TSearch, IStrategy<TResponse, TRequest>>(); | |
public void AddList(TSearch op, IStrategy<TResponse, TRequest> str) | |
{ | |
_dicStrategy.Add(op, str); | |
} |
NewerOlder