Esempio n. 1
0
        /// <summary>
        /// If we skip empty lines or it is a comment or is is excluded by settings
        /// </summary>
        /// <param name="line">Input line we are testing</param>
        /// <returns>True if line is skipped</returns>
        private bool MustIgnoreLine(string line)
        {
            if (RecordInfo.IgnoreEmptyLines)
            {
                if ((RecordInfo.IgnoreEmptySpaces && line.TrimStart().Length == 0) ||
                    line.Length == 0)
                {
                    return(true);
                }
            }

            if (!String.IsNullOrEmpty(RecordInfo.CommentMarker))
            {
                if ((RecordInfo.CommentAnyPlace && line.TrimStart().StartsWith(RecordInfo.CommentMarker)) ||
                    line.StartsWith(RecordInfo.CommentMarker))
                {
                    return(true);
                }
            }

            if (RecordInfo.RecordCondition != RecordCondition.None)
            {
                switch (RecordInfo.RecordCondition)
                {
                case RecordCondition.ExcludeIfBegins:
                    return(ConditionHelper.BeginsWith(line, RecordInfo.RecordConditionSelector));

                case RecordCondition.IncludeIfBegins:
                    return(!ConditionHelper.BeginsWith(line, RecordInfo.RecordConditionSelector));

                case RecordCondition.ExcludeIfContains:
                    return(ConditionHelper.Contains(line, RecordInfo.RecordConditionSelector));

                case RecordCondition.IncludeIfContains:
                    return(!ConditionHelper.Contains(line, RecordInfo.RecordConditionSelector));

                case RecordCondition.ExcludeIfEnclosed:
                    return(ConditionHelper.Enclosed(line, RecordInfo.RecordConditionSelector));

                case RecordCondition.IncludeIfEnclosed:
                    return(!ConditionHelper.Enclosed(line, RecordInfo.RecordConditionSelector));

                case RecordCondition.ExcludeIfEnds:
                    return(ConditionHelper.EndsWith(line, RecordInfo.RecordConditionSelector));

                case RecordCondition.IncludeIfEnds:
                    return(!ConditionHelper.EndsWith(line, RecordInfo.RecordConditionSelector));

                case RecordCondition.ExcludeIfMatchRegex:
                    return(RecordInfo.RecordConditionRegEx.IsMatch(line));

                case RecordCondition.IncludeIfMatchRegex:
                    return(!RecordInfo.RecordConditionRegEx.IsMatch(line));
                }
            }

            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// If we skip empty lines or it is a comment or is is excluded by settings
        /// </summary>
        /// <param name="line">Input line we are testing</param>
        /// <returns>True if line is skipped</returns>
        private bool MustIgnoreLine(string line)
        {
            if (mRecordInfo.IgnoreEmptyLines)
            {
                if ((mRecordInfo.IgnoreEmptySpaces && string.IsNullOrWhiteSpace(line)) ||
                    line.Length == 0)
                {
                    return(true);
                }
            }

            if (!string.IsNullOrEmpty(mRecordInfo.CommentMarker))
            {
                if ((mRecordInfo.CommentAnyPlace && StartsWithIgnoringWhiteSpaces(line, mRecordInfo.CommentMarker, StringComparison.Ordinal)) ||
                    line.StartsWith(mRecordInfo.CommentMarker, StringComparison.Ordinal))
                {
                    return(true);
                }
            }

            if (mRecordInfo.RecordCondition != RecordCondition.None)
            {
                switch (mRecordInfo.RecordCondition)
                {
                case RecordCondition.ExcludeIfBegins:
                    return(ConditionHelper.BeginsWith(line, mRecordInfo.RecordConditionSelector));

                case RecordCondition.IncludeIfBegins:
                    return(!ConditionHelper.BeginsWith(line, mRecordInfo.RecordConditionSelector));

                case RecordCondition.ExcludeIfContains:
                    return(ConditionHelper.Contains(line, mRecordInfo.RecordConditionSelector));

                case RecordCondition.IncludeIfContains:
                    return(!ConditionHelper.Contains(line, mRecordInfo.RecordConditionSelector));

                case RecordCondition.ExcludeIfEnclosed:
                    return(ConditionHelper.Enclosed(line, mRecordInfo.RecordConditionSelector));

                case RecordCondition.IncludeIfEnclosed:
                    return(!ConditionHelper.Enclosed(line, mRecordInfo.RecordConditionSelector));

                case RecordCondition.ExcludeIfEnds:
                    return(ConditionHelper.EndsWith(line, mRecordInfo.RecordConditionSelector));

                case RecordCondition.IncludeIfEnds:
                    return(!ConditionHelper.EndsWith(line, mRecordInfo.RecordConditionSelector));

                case RecordCondition.ExcludeIfMatchRegex:
                    return(mRecordInfo.RecordConditionRegEx.IsMatch(line));

                case RecordCondition.IncludeIfMatchRegex:
                    return(!mRecordInfo.RecordConditionRegEx.IsMatch(line));
                }
            }

            return(false);
        }
//		private static ErrorManager CreateAndAssign(object[] values)
//		{
//			ErrorManager record = new ErrorManager();
//			record.mErrorMode = (ErrorMode) values[0];
//			record.temp = (string) values[1];
//			
//			return record;
//		}
		
		
		private bool MustIgnoreLine(string line)
		{
			if (mIgnoreEmptyLines)
				if ((mIgnoreEmptySpaces && line.TrimStart().Length == 0) || 
					line.Length == 0) 
					return true;
		
		
			if (mCommentMarker != null && mCommentMarker.Length > 0)
				if ( (mCommentAnyPlace && line.TrimStart().StartsWith(mCommentMarker)) ||
					line.StartsWith(mCommentMarker))
					return true;
			


			if (mRecordCondition != RecordCondition.None)
			{
				switch (mRecordCondition)
				{
					case RecordCondition.ExcludeIfBegins:
						return ConditionHelper.BeginsWith(line, mRecordConditionSelector);
					case RecordCondition.IncludeIfBegins:
						return ! ConditionHelper.BeginsWith(line, mRecordConditionSelector);

					case RecordCondition.ExcludeIfContains:
						return ConditionHelper.Contains(line, mRecordConditionSelector);
					case RecordCondition.IncludeIfContains:
						return ConditionHelper.Contains(line, mRecordConditionSelector);


					case RecordCondition.ExcludeIfEnclosed:
						return ConditionHelper.Enclosed(line, mRecordConditionSelector);
					case RecordCondition.IncludeIfEnclosed:
						return ! ConditionHelper.Enclosed(line, mRecordConditionSelector);
					
					case RecordCondition.ExcludeIfEnds:
						return ConditionHelper.EndsWith(line, mRecordConditionSelector);
					case RecordCondition.IncludeIfEnds:
						return ! ConditionHelper.EndsWith(line, mRecordConditionSelector);

				#if ! MINI
					case RecordCondition.ExcludeIfMatchRegex:
						return mConditionRegEx.IsMatch(line);
					case RecordCondition.IncludeIfMatchRegex:
						return ! mConditionRegEx.IsMatch(line);
				#endif

				}
			}
			
			return false;
		}