Last active
August 29, 2015 14:25
-
-
Save Fhernd/bb4ff3c7001977235f52 to your computer and use it in GitHub Desktop.
Demostración del uso del atributo `Conditional` sobre un método.
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
// OrtizOL - xCSw - http://ortizol.blogspot.com | |
#define win7 | |
#define win8 | |
#define release | |
#undef win2000 | |
using System; | |
using System.Diagnostics; | |
namespace Recetas.Capitulo01 | |
{ | |
public class Plataforma | |
{ | |
[Conditional("DEBUG")] | |
public static void MetodoCondicional() | |
{ | |
Console.WriteLine ("Ingresó al método `MetodoCondicional`."); | |
} | |
public static void Main (string[] args) | |
{ | |
Console.WriteLine(Environment.NewLine); | |
// declara objeto string para almacenar la plataforma identificada | |
// de acuerdo a la directiva evaluada | |
string plataformaIdentificada; | |
#if win8 | |
plataformaIdentificada = "Microsoft Windows 8"; | |
#elif winXP | |
plataformaIdentificada = "Microsoft Windows XP"; | |
#elif win2000 | |
plataformaIdentificada = "Microsoft Windows 2000"; | |
#elif win7 | |
plataformaIdentificada = "Microsoft Windows 7"; | |
#else | |
plataformaIdentificada = "Desconocida"; | |
#endif | |
Console.WriteLine ("Plataforma identificada: {0}", plataformaIdentificada); | |
// Ahora se invoca el método condicional. Esto ocurriré siempre | |
// y cuando el símbolo `DEBUG` haya sido definido: | |
MetodoCondicional (); | |
Console.WriteLine(Environment.NewLine); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment