This file contains hidden or 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 Garaje<T> where T : Vehiculo | |
| { | |
| private bool _gps; | |
| private string _color; | |
| public Garaje<T> Pintar(string color) | |
| { | |
| _color = color; | |
| return this; | |
| } |
This file contains hidden or 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
| Garaje<Coche> garajeCoche = new Garaje<Coche>(); | |
| Garaje<Barco> garajeBarco = garajeCoche | |
| .Pintar("Verde") | |
| .ConGps(true) | |
| .Mutar<Moto>() | |
| .MutarABarco(); | |
| Console.WriteLine(garajeBarco.ToString()); |
This file contains hidden or 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
| FabricarCoche() | |
| .Pintar("Rojo") | |
| .ConMotor(FabricarMotor() | |
| .ConCilindros("6V") | |
| .ConPotencia("190cv")) | |
| .ConPuertas(5) | |
| .GpsIntegrado(); |
This file contains hidden or 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 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) | |
| { |
This file contains hidden or 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
| Garaje garaje = new Garaje(Perfil.Sport); | |
| garaje | |
| .MaximaCapacidad(5) | |
| .ConfiguraCoche((coche, perfil) => { }) | |
| .ConfiguraMoto(moto => { }) | |
| .ConfiguraBici(bici => { }); |
This file contains hidden or 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 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; |
This file contains hidden or 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
| 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) |
This file contains hidden or 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
| 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") |
This file contains hidden or 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
| 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); |
This file contains hidden or 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
| IEnumerable<Persona> resultado = personas | |
| .Where(p => p.Apellido.StartsWith("A")) | |
| .Take(10); | |
| IEnumerable<Persona> resultado2 = personas | |
| .Take(10) | |
| .Where(p => p.Apellido.StartsWith("A")); |