Skip to content

Instantly share code, notes, and snippets.

View jesuscampos's full-sized avatar
🏠
Working from home

Jesús jesuscampos

🏠
Working from home
View GitHub Profile
@jesuscampos
jesuscampos / .cs
Last active December 5, 2017 23:12
class Garaje<T> where T : Vehiculo
{
private bool _gps;
private string _color;
public Garaje<T> Pintar(string color)
{
_color = color;
return this;
}
Garaje<Coche> garajeCoche = new Garaje<Coche>();
Garaje<Barco> garajeBarco = garajeCoche
.Pintar("Verde")
.ConGps(true)
.Mutar<Moto>()
.MutarABarco();
Console.WriteLine(garajeBarco.ToString());
FabricarCoche()
.Pintar("Rojo")
.ConMotor(FabricarMotor()
.ConCilindros("6V")
.ConPotencia("190cv"))
.ConPuertas(5)
.GpsIntegrado();
class Garaje
{
private Coche coche = new Coche();
private Bici bici = new Bici();
private Moto moto = new Moto();
private int maximaCapacidad = 3;
private Perfil perfil { get; set; }
public Garaje(Perfil perfil = Perfil.Moderado)
{
Garaje garaje = new Garaje(Perfil.Sport);
garaje
.MaximaCapacidad(5)
.ConfiguraCoche((coche, perfil) => { })
.ConfiguraMoto(moto => { })
.ConfiguraBici(bici => { });
class Coche
{
private string color;
private bool gps;
private int puertas;
private Motor motor;
private Ruedas ruedas = new Ruedas();
private Func<Motor, decimal> funcionConsumo;
public int Peso { get; set; } = 1000;
@jesuscampos
jesuscampos / .cs
Last active December 5, 2017 23:57
Garaje garaje = new Garaje(Perfil.Sport);
garaje
.MaximaCapacidad(5)
.ConfiguraCoche((coche, perfil) =>
{
coche
.Pintar(perfil == Perfil.Sport ? "Rojo" : "Azul")
.PesoTotal(1200)
.ConGps(true)
.Puertas(perfil == Perfil.Sport ? 3 : 5)
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "SwaggerDemoApi");
c.IncludeXmlComments(string.Format(@"{0}\bin\SwaggerDemoApi.XML",
System.AppDomain.CurrentDomain.BaseDirectory));
c.DescribeAllEnumsAsStrings();
c.OAuth2("oauth2")
.Description("OAuth2 Implicit Grant")
.Flow("implicit")
List<Persona> personas = repositorio.GetPersonas();
IEnumerable<string> resultado = personas
.Where(p => p.Apellido.StartsWith("A"))
.OrderBy(p => p.Edad)
.Select(p => p.Nombre + " " + p.Apellido);
IEnumerable<Persona> resultado = personas
.Where(p => p.Apellido.StartsWith("A"))
.Take(10);
IEnumerable<Persona> resultado2 = personas
.Take(10)
.Where(p => p.Apellido.StartsWith("A"));