private static PersonalVisibility GetVisibility(PersonalContactDegree contactDegree, PersonalVisibilitySettings visibilitySettings) { switch (contactDegree) { case PersonalContactDegree.Self: case PersonalContactDegree.Representee: // A representative of a representee can always see everything of that representee. return(PersonalVisibility.All); case PersonalContactDegree.Representative: // A representee can always see the name of their representative. return(visibilitySettings.FirstDegreeVisibility | PersonalVisibility.Name); case PersonalContactDegree.FirstDegree: return(visibilitySettings.FirstDegreeVisibility); case PersonalContactDegree.SecondDegree: return(visibilitySettings.SecondDegreeVisibility); case PersonalContactDegree.Public: return(visibilitySettings.PublicVisibility); default: return(visibilitySettings.PublicVisibility & PersonalVisibilitySettings.Anonymous); } }
internal static bool CanAccess(PersonalContactDegree contactDegree, PersonalVisibilitySettings visibilitySettings, PersonalVisibility visibility) { var contactVisibility = visibilitySettings == null?GetAnonymousVisibility(contactDegree) : GetVisibility(contactDegree, visibilitySettings); return(contactVisibility.IsFlagSet(visibility)); }