Esempio n. 1
0
        private static ConfigurationRolePredicateEntry CreateIncludeEntry(XmlNode node)
        {
            Assert.ArgumentNotNull(node, nameof(node));

            var result = new ConfigurationRolePredicateEntry(node?.Attributes?["domain"]?.Value);

            result.Pattern = node?.Attributes?["pattern"]?.Value;

            return(result);
        }
		/// <summary>
		/// Checks if a preset includes a given item
		/// </summary>
		protected PredicateResult Includes(ConfigurationRolePredicateEntry entry, Role role)
		{
			// domain match
			if(role.Domain == null || !role.Domain.Name.Equals(entry.Domain, StringComparison.OrdinalIgnoreCase)) return new PredicateResult(false);

			// pattern match
			if(!string.IsNullOrWhiteSpace(entry.Pattern) && !Regex.IsMatch(role.Name.Split('\\').Last(), entry.Pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled)) return new PredicateResult(false);
			
			// pattern is either null or white space, or it matches
			return new PredicateResult(true);
		}
        /// <summary>
        /// Checks if a preset includes a given item
        /// </summary>
        protected PredicateResult Includes(ConfigurationRolePredicateEntry entry, IRoleData role)
        {
            var split = role.RoleName.Split('\\');

            var domain = split[0];
            var roleName = split.Last();

            // domain match
            if(!string.IsNullOrWhiteSpace(entry.Domain) && !domain.Equals(entry.Domain, StringComparison.OrdinalIgnoreCase)) return new PredicateResult(false);

            // pattern match
            if(!string.IsNullOrWhiteSpace(entry.Pattern) && !Regex.IsMatch(roleName, entry.Pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled)) return new PredicateResult(false);

            // pattern is either null or white space, or it matches
            return new PredicateResult(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Checks if a preset includes a given item
        /// </summary>
        protected PredicateResult Includes(ConfigurationRolePredicateEntry entry, IRoleData role)
        {
            var split = role.RoleName.Split('\\');

            var domain   = split[0];
            var roleName = split.Last();

            // domain match
            if (!string.IsNullOrWhiteSpace(entry.Domain) && !domain.Equals(entry.Domain, StringComparison.OrdinalIgnoreCase))
            {
                return(new PredicateResult(false));
            }

            // pattern match
            if (!string.IsNullOrWhiteSpace(entry.Pattern) && !Regex.IsMatch(roleName, entry.Pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled))
            {
                return(new PredicateResult(false));
            }

            // pattern is either null or white space, or it matches
            return(new PredicateResult(true));
        }
        private static ConfigurationRolePredicateEntry CreateIncludeEntry(XmlNode node)
        {
            Assert.ArgumentNotNull(node, nameof(node));

            var result = new ConfigurationRolePredicateEntry(node?.Attributes?["domain"]?.Value);

            result.Pattern = node?.Attributes?["pattern"]?.Value;

            return result;
        }