public bool HasPrivilege(PrivilegeFor forType, string identifier, string privilegeName) { if (Authorisations.Authorisations == null || Authorisations.Authorisations.Count == 0) { return(false); } string sre = string.Empty; switch (forType) { case PrivilegeFor.CvrNumber: sre = _cvrNumberRegEx; break; case PrivilegeFor.ProductionUnit: sre = _productionUnitRegEx; break; } foreach (AuthorisationType at in Authorisations.Authorisations) { Regex re = new Regex(sre); if (re.IsMatch(at.resource)) { Match m = re.Match(at.resource); string localIdentifier = m.Groups[1].Value; if (localIdentifier == identifier) { if (at.Privilege != null && at.Privilege.Count > 0) { foreach (PrivilegeType pt in at.Privilege) { if (pt.Value == privilegeName) { return(true); } } } } } } return(false); }
public bool HasPrivilege(PrivilegeFor forType, string identifier, string privilegeName) { if (Authorisations.Authorisations == null || Authorisations.Authorisations.Count == 0) return false; string sre = string.Empty; switch(forType){ case PrivilegeFor.CvrNumber: sre = _cvrNumberRegEx; break; case PrivilegeFor.ProductionUnit: sre = _productionUnitRegEx; break; } foreach (AuthorisationType at in Authorisations.Authorisations) { Regex re = new Regex(sre); if (re.IsMatch(at.resource)) { Match m = re.Match(at.resource); string localIdentifier = m.Groups[1].Value; if (localIdentifier == identifier) { if (at.Privilege != null && at.Privilege.Count > 0) { foreach (PrivilegeType pt in at.Privilege) { if (pt.Value == privilegeName) return true; } } } } } return false; }