void ProceeProblemRight(ProblemRights problemAllow, ProblemRights problemDeny, ContestRights contestAllow, ContestRights baseRights, ProblemRights concreteRights, ref ProblemRights pr) { if ((baseRights & contestAllow) != 0) { if ((concreteRights & problemDeny) != 0) { pr |= problemDeny; } else { pr |= problemAllow; } } else { if ((concreteRights & problemAllow) != 0) { pr |= problemAllow; } else { pr |= problemDeny; } } }
public ProblemRights GetProblemRights(int problemID) { ProblemRights pr = ProblemRights.None; ContestRights baseRights = GetContestRights(Problem.GetProblem(problemID).ContestID); ProblemRights concreteRights = DataProvider.Provider.UserManager.GetProblemRights(id, problemID); for (int i = 1; i <= 1024; i *= 4) { ProceeProblemRight((ProblemRights)i, (ProblemRights)(i * 2), (ContestRights)i, baseRights, concreteRights, ref pr); } return(pr); }