Exemplo n.º 1
0
        static void Main(string[] args)
        {
            SecuredSection secured    = new SecuredSection();
            Director       director   = new Director();
            Manager        manager    = new Manager();
            Programmer     programmer = new Programmer();

            director.TryAccess(secured);
            manager.TryAccess(secured);
            programmer.TryAccess(secured);
        }
Exemplo n.º 2
0
        public void TryAccess(SecuredSection secured)
        {
            object[] attributes = type.GetCustomAttributes(typeof(AccessLevelAttribute), false);
            foreach (var attribute in attributes)
            {
                level      = attribute as AccessLevelAttribute;
                attribName = level.Level;
            }

            secured.Access(attribName);
        }