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); }
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); }