コード例 #1
0
        internal CharSubtraction(IBaseGroup baseGroup, IExcludedGroup excludedGroup)
        {
            if (baseGroup == null)
                throw new ArgumentNullException(nameof(baseGroup));

            if (excludedGroup == null)
                throw new ArgumentNullException(nameof(excludedGroup));

            _baseGroup = baseGroup;
            _excludedGroup = excludedGroup;
        }
コード例 #2
0
        /// <summary>
        /// проверяет наличия элемента в группе, у которого значение свойства
        /// , имя которого определено вторым аргументом метода
        /// , равно значению, определяемого третьим аргументом
        /// </summary>
        /// <param name="group">группа элементов</param>
        /// <param name="propName">имя свойства</param>
        /// <param name="value">значение</param>
        /// <param name="recursive"><c>true</c>, ресурсивный обход элементов, если элемент является также группой</param>
        /// <param name="comparer">функция сравнения значений</param>
        /// <param name="contains">дополнительная функция обхода элементов у негруппового объекта</param>
        /// <returns></returns>
        public static bool ContainsByPropName(IBaseGroup group, string propName, object value,
                                              bool recursive = false, ReturnAction <object, object, bool> comparer = null,
                                              ReturnAction <object, object, bool> contains = null)
        {
            if (group == null)
            {
                ExceptionGenerator.Run <NullReferenceException>("Группа не определена");
            }

            if (group is IGroupObject)
            {
                var groupObject = group as IGroupObject;
                if (groupObject.Group != null)
                {
                    foreach (var obj in groupObject.Group)
                    {
                        if (IsObjectHavingValue(obj, propName, value, recursive, comparer, contains))
                        {
                            return(true);
                        }
                    }
                }
            }
            else if (group is IGroupOfOne)
            {
                var groupOfOne = group as IGroupOfOne;
                if (groupOfOne.Element != null)
                {
                    if (IsObjectHavingValue(groupOfOne.Element, propName, value, recursive, comparer, contains))
                    {
                        return(true);
                    }
                }
            }
            else if (group is IGroup)
            {
                var group__ = group as IGroup;
                foreach (var obj in group__)
                {
                    if (IsObjectHavingValue(obj, propName, value, recursive, comparer, contains))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #3
0
 /// <summary>
 /// Returns a pattern that matches a character from a specified base group except characters from a specified excluded group.
 /// </summary>
 /// <param name="baseGroup">A base group.</param>
 /// <param name="excludedGroup">An excluded group.</param>
 /// <exception cref="ArgumentNullException"><paramref name="baseGroup"/> or <paramref name="excludedGroup"/> is <c>null</c>.</exception>
 public static CharSubtraction Except(this IBaseGroup baseGroup, IExcludedGroup excludedGroup)
 {
     return(new CharSubtraction(baseGroup, excludedGroup));
 }
コード例 #4
0
ファイル: CharSubtraction.cs プロジェクト: yogesh/LinqToRegex
 internal CharSubtraction(IBaseGroup baseGroup, IExcludedGroup excludedGroup)
 {
     _baseGroup     = baseGroup ?? throw new ArgumentNullException(nameof(baseGroup));
     _excludedGroup = excludedGroup ?? throw new ArgumentNullException(nameof(excludedGroup));
 }
コード例 #5
0
        /// <summary>
        /// Appends a pattern that matches a character from a specified base group except characters from a specified excluded group.
        /// </summary>
        /// <param name="baseGroup">A base group.</param>
        /// <param name="excludedGroup">An excluded group.</param>
        /// <exception cref="ArgumentNullException"><paramref name="baseGroup"/> or <paramref name="excludedGroup"/> is <c>null</c>.</exception>
        public void AppendSubtraction(IBaseGroup baseGroup, IExcludedGroup excludedGroup)
        {
            if (baseGroup == null)
                throw new ArgumentNullException(nameof(baseGroup));

            if (excludedGroup == null)
                throw new ArgumentNullException(nameof(excludedGroup));

            AppendCharGroupStart();

            baseGroup.AppendBaseGroupTo(this);

            AppendDirect('-');

            excludedGroup.AppendExcludedGroupTo(this);

            AppendCharGroupEnd();
        }