// ===++===
//
// OrtizOL
//
// ===--===
/*============================================================
//
// Clase: Crud.cs
//
// Propósito: Demostración de uso de combinaciones en
// enumeraciones.
//
============================================================*/
using System;
namespace Articulos.Cap03
{
public enum Crud
{
Ninguna = 0,
Crear = 1,
Leer = 2,
Actualizar = 4,
Eliminar = 8
}
internal class Usuario
{
public string Id
{
get;
set;
}
public string Contrasegnia
{
get;
set;
}
public Crud PermisosBaseDatos
{
get;
set;
}
}
internal class PruebaCrud
{
public static void Main()
{
Usuario usuario = new Usuario();
usuario.Id = "infzero";
usuario.Contrasegnia = "1ng3n1er1@";
// Establece los permisos para el usuario:
Crud permisos = Crud.Crear | Crud.Actualizar;
usuario.PermisosBaseDatos = permisos;
//Mostramos los permisos para el usuario creado:
Console.WriteLine("Permisos para {0}: {1}", usuario.Id, usuario.PermisosBaseDatos.ToString("F"));
}
}
}
Ly8gPT09Kys9PT0KLy8KLy8gICAgT3J0aXpPTAovLwovLyA9PT0tLT09PQovKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQovLwovLyBDbGFzZTogQ3J1ZC5jcwovLwovLyBQcm9ww7NzaXRvOiBEZW1vc3RyYWNpw7NuIGRlIHVzbyBkZSBjb21iaW5hY2lvbmVzIGVuIAovLyBlbnVtZXJhY2lvbmVzLgovLwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLwoKdXNpbmcgU3lzdGVtOwoKbmFtZXNwYWNlIEFydGljdWxvcy5DYXAwMwp7CiAgICBwdWJsaWMgZW51bSBDcnVkCiAgICB7CiAgICAgICAgTmluZ3VuYSA9IDAsCiAgICAgICAgQ3JlYXIgPSAxLAogICAgICAgIExlZXIgPSAyLAogICAgICAgIEFjdHVhbGl6YXIgPSA0LAogICAgICAgIEVsaW1pbmFyID0gOAogICAgfQogICAgCiAgICBpbnRlcm5hbCBjbGFzcyBVc3VhcmlvCiAgICB7CiAgICAgICAgcHVibGljIHN0cmluZyBJZAogICAgICAgIHsKICAgICAgICAgICAgZ2V0OwogICAgICAgICAgICBzZXQ7CiAgICAgICAgfQogICAgICAgIAogICAgICAgIHB1YmxpYyBzdHJpbmcgQ29udHJhc2VnbmlhCiAgICAgICAgewogICAgICAgICAgICBnZXQ7CiAgICAgICAgICAgIHNldDsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgcHVibGljIENydWQgUGVybWlzb3NCYXNlRGF0b3MKICAgICAgICB7CiAgICAgICAgICAgIGdldDsKICAgICAgICAgICAgc2V0OwogICAgICAgIH0KICAgIH0KICAgIAogICAgaW50ZXJuYWwgY2xhc3MgUHJ1ZWJhQ3J1ZAogICAgewogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKICAgICAgICB7CiAgICAgICAgICAgIFVzdWFyaW8gdXN1YXJpbyA9IG5ldyBVc3VhcmlvKCk7CiAgICAgICAgICAgIAogICAgICAgICAgICB1c3VhcmlvLklkID0gImluZnplcm8iOwogICAgICAgICAgICB1c3VhcmlvLkNvbnRyYXNlZ25pYSA9ICIxbmczbjFlcjFAIjsKICAgICAgICAgICAgCiAgICAgICAgICAgIC8vIEVzdGFibGVjZSBsb3MgcGVybWlzb3MgcGFyYSBlbCB1c3VhcmlvOgogICAgICAgICAgICBDcnVkIHBlcm1pc29zID0gQ3J1ZC5DcmVhciB8IENydWQuQWN0dWFsaXphcjsKICAgICAgICAgICAgdXN1YXJpby5QZXJtaXNvc0Jhc2VEYXRvcyA9IHBlcm1pc29zOwogICAgICAgICAgICAKICAgICAgICAgICAgLy9Nb3N0cmFtb3MgbG9zIHBlcm1pc29zIHBhcmEgZWwgdXN1YXJpbyBjcmVhZG86CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJQZXJtaXNvcyBwYXJhIHswfTogezF9IiwgdXN1YXJpby5JZCwgdXN1YXJpby5QZXJtaXNvc0Jhc2VEYXRvcy5Ub1N0cmluZygiRiIpKTsKICAgICAgICB9CiAgICB9Cn0=