public Field[] getFields(AccessLevel accessLevel, AccessLevelRule rule) { List <Field> output = new List <Field>(); if (parent != null) { output.AddRange(parent.getFields(accessLevel, rule)); } foreach (Field fieldsValue in fields.Values) { if (AccessLevelMethods.canAccess(accessLevel, fieldsValue.modifiers.accessLevel)) { output.Append(fieldsValue); } } return(output.ToArray()); }
public static bool canAccess(AccessLevel inAccess, AccessLevel objectAccesLevel, AccessLevelRule rule = AccessLevelRule.inLessThanEqualTo) { if (rule == AccessLevelRule.inLessThanEqualTo) { return(inAccess <= objectAccesLevel); } if (rule == AccessLevelRule.@equals) { return(inAccess == objectAccesLevel); } throw new Exception("No access rule specified"); }