예제 #1
0
        /// <summary>
        /// Checks if a preset includes a given item
        /// </summary>
        protected PredicateResult Includes(ConfigurationUserPredicateEntry entry, User user)
        {
            // domain match
            if (user.Domain == null || !user.Domain.Name.Equals(entry.Domain, StringComparison.OrdinalIgnoreCase)) return new PredicateResult(false);

            // pattern match
            if (!string.IsNullOrWhiteSpace(entry.Pattern) && !Regex.IsMatch(user.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);
        }
        private static ConfigurationUserPredicateEntry CreateIncludeEntry(XmlNode node)
        {
            Assert.ArgumentNotNull(node, nameof(node));

            var result = new ConfigurationUserPredicateEntry(node?.Attributes?["domain"]?.Value)
            {
                Pattern = node?.Attributes?["pattern"]?.Value
            };


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

            // pattern match
            if (!string.IsNullOrWhiteSpace(entry.Pattern) && !Regex.IsMatch(user.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));
        }
예제 #4
0
        private static ConfigurationUserPredicateEntry CreateIncludeEntry(XmlNode node)
        {
            Assert.ArgumentNotNull(node, nameof(node));

            var result = new ConfigurationUserPredicateEntry(node?.Attributes?["domain"]?.Value)
            {
                Pattern = node?.Attributes?["pattern"]?.Value
            };

            return result;
        }