Exemplo n.º 1
0
        /// <summary>
        /// Checks if there is an access to the given type
        /// The check perfomed, using RightsCheckList attribute
        /// If there is no such attribute on the given type, access is granted
        /// </summary>
        /// <exception cref="ArgumentNullException"></exception>
        /// <param name="dataType"></param>
        /// <returns></returns>
        public bool CanReadTypeData(Type dataType)
        {
            if (HasFullRights)
            {
                return(true);
            }

            if (dataType == null)
            {
                throw new ArgumentNullException();
            }

            var entitiesToCheck = GetEntitiesToCheck(dataType);

            if (entitiesToCheck == null || entitiesToCheck.Count == 0)
            {
                return(true);
            }

            foreach (var entityName in entitiesToCheck)
            {
                if (!EntityRights.TryGetValue(entityName, out var right) || right.EntityAccessLevel == EntityAccessLevel.No)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        private bool TryGetEntityRight(string entityName, out EntityRightData right)
        {
            right = null;
            if (EntityRights == null || string.IsNullOrEmpty(entityName))
            {
                return(false);
            }

            return(EntityRights.TryGetValue(entityName, out right));
        }