Exemplo n.º 1
0
        public PredicateResult Includes(IItemData itemData)
        {
            Assert.ArgumentNotNull(itemData, "itemData");

            var result = new PredicateResult(true);

            PredicateResult priorityResult = null;

            foreach (var entry in _includeEntries)
            {
                result = Includes(entry, itemData);

                if (result.IsIncluded)
                {
                    result.PredicateComponentId = entry.Name;

                    return(result);                    // it's definitely included if anything includes it
                }

                if (!string.IsNullOrEmpty(result.Justification))
                {
                    priorityResult = result;                                                              // a justification means this is probably a more 'important' fail than others
                }
            }

            return(priorityResult ?? result);            // return the last failure
        }
        protected virtual PredicateResult ExcludeMatches(IncludeEntry entry, ISourceItem item)
        {
            PredicateResult result = ExcludeMatchesTemplate(entry.Exclude, item.TemplateName);

            if (!result.IsIncluded)
            {
                return(result);
            }

            result = ExcludeMatchesTemplateId(entry.Exclude, item.TemplateId);

            if (!result.IsIncluded)
            {
                return(result);
            }

            result = ExcludeMatchesPath(entry.Exclude, item.ItemPath);

            if (!result.IsIncluded)
            {
                return(result);
            }

            result = ExcludeMatchesId(entry.Exclude, item.Id);

            return(result);
        }
        public PredicateResult Includes(ISourceItem item)
        {
            // no entries = include everything
            if (_preset.FirstOrDefault() == null)
            {
                return(new PredicateResult(true));
            }

            var             result         = new PredicateResult(true);
            PredicateResult priorityResult = null;

            foreach (var entry in _preset)
            {
                result = Includes(entry, item);

                if (result.IsIncluded)
                {
                    return(result);                                   // it's definitely included if anything includes it
                }
                if (!string.IsNullOrEmpty(result.Justification))
                {
                    priorityResult = result;                                                              // a justification means this is probably a more 'important' fail than others
                }
            }

            return(priorityResult ?? result);            // return the last failure
        }
Exemplo n.º 4
0
        protected virtual PredicateResult ExcludeMatches(PresetTreeRoot entry, IItemData itemData)
        {
            PredicateResult result = ExcludeMatchesPath(entry.Exclude, itemData.Path);

            if (!result.IsIncluded)
            {
                return(result);
            }

            return(result);
        }
        public PredicateResult Includes(IItemData itemData)
        {
            Assert.ArgumentNotNull(itemData, "itemData");

            var result = new PredicateResult(true);

            PredicateResult priorityResult = null;

            foreach (var entry in _includeEntries)
            {
                result = Includes(entry, itemData);

                if (result.IsIncluded) return result; // it's definitely included if anything includes it
                if (!string.IsNullOrEmpty(result.Justification)) priorityResult = result; // a justification means this is probably a more 'important' fail than others
            }

            return priorityResult ?? result; // return the last failure
        }
Exemplo n.º 6
0
        public PredicateResult Includes(IRoleData role)
        {
            Assert.ArgumentNotNull(role, nameof(role));

            // no entries = include everything
            if (_includeEntries.Count == 0) return new PredicateResult(true);

            var result = new PredicateResult(true);

            PredicateResult priorityResult = null;

            foreach (var entry in _includeEntries)
            {
                result = Includes(entry, role);

                if (result.IsIncluded) return result; // it's definitely included if anything includes it
                if (!string.IsNullOrEmpty(result.Justification)) priorityResult = result; // a justification means this is probably a more 'important' fail than others
            }

            return priorityResult ?? result; // return the last failure
        }
        public PredicateResult Includes(ISerializedReference item)
        {
            var             result         = new PredicateResult(true);
            PredicateResult priorityResult = null;

            foreach (var entry in _preset)
            {
                result = Includes(entry, item);

                if (result.IsIncluded)
                {
                    return(result);                                   // it's definitely included if anything includes it
                }
                if (!string.IsNullOrEmpty(result.Justification))
                {
                    priorityResult = result;                                                              // a justification means this is probably a more 'important' fail than others
                }
            }

            return(priorityResult ?? result);            // return the last failure
        }
        protected virtual PredicateResult ExcludeMatches(IncludeEntry entry, ISerializedReference reference)
        {
            PredicateResult result = ExcludeMatchesPath(entry.Exclude, reference.ItemPath);

            if (!result.IsIncluded)
            {
                return(result);
            }

            // many times the ISerializedReference may also have an item ref in it (e.g. be a serialized item)
            // in this case we can check additional criteria
            var item = reference as ISerializedItem;

            if (item == null)
            {
                return(result);
            }

            result = ExcludeMatchesTemplateId(entry.Exclude, ID.Parse(item.TemplateId));

            if (!result.IsIncluded)
            {
                return(result);
            }

            result = ExcludeMatchesTemplate(entry.Exclude, item.TemplateName);

            if (!result.IsIncluded)
            {
                return(result);
            }

            result = ExcludeMatchesId(entry.Exclude, ID.Parse(item.Id));

            return(result);
        }
        public PredicateResult Includes(ISourceItem item)
        {
            // no entries = include everything
            if (_preset.FirstOrDefault() == null) return new PredicateResult(true);

            var result = new PredicateResult(true);
            PredicateResult priorityResult = null;
            foreach (var entry in _preset)
            {
                result = Includes(entry, item);

                if (result.IsIncluded) return result; // it's definitely included if anything includes it
                if (!string.IsNullOrEmpty(result.Justification)) priorityResult = result; // a justification means this is probably a more 'important' fail than others
            }

            return priorityResult ?? result; // return the last failure
        }
        public PredicateResult Includes(ISerializedReference item)
        {
            var result = new PredicateResult(true);
            PredicateResult priorityResult = null;
            foreach (var entry in _preset)
            {
                result = Includes(entry, item);

                if (result.IsIncluded) return result; // it's definitely included if anything includes it
                if (!string.IsNullOrEmpty(result.Justification)) priorityResult = result; // a justification means this is probably a more 'important' fail than others
            }

            return priorityResult ?? result; // return the last failure
        }