Exemplo n.º 1
0
        static IMessage MakeMessageInternal(
            TextMessageCapture capture,
            IRegex headRe,
            IRegex bodyRe,
            ref IMatch bodyMatch,
            IFieldsProcessor fieldsProcessor,
            MakeMessageFlags makeMessageFlags,
            DateTime sourceTime,
            ITimeOffsets timeOffsets,
            MessagesBuilderCallback threadLocalCallbackImpl
            )
        {
            if (bodyRe != null)
            {
                if (!bodyRe.Match(capture.BodyBuffer, capture.BodyIndex, capture.BodyLength, ref bodyMatch))
                {
                    return(null);
                }
            }

            int idx = 0;

            Group[] groups;

            fieldsProcessor.Reset();
            fieldsProcessor.SetSourceTime(sourceTime);
            fieldsProcessor.SetPosition(capture.BeginPosition);
            fieldsProcessor.SetTimeOffsets(timeOffsets);

            groups = capture.HeaderMatch.Groups;
            for (int i = 1; i < groups.Length; ++i)
            {
                var g = groups[i];
                fieldsProcessor.SetInputField(idx++, new StringSlice(capture.HeaderBuffer, g.Index, g.Length));
            }

            if (bodyRe != null)
            {
                groups = bodyMatch.Groups;
                for (int i = 1; i < groups.Length; ++i)
                {
                    var g = groups[i];
                    fieldsProcessor.SetInputField(idx++, new StringSlice(capture.BodyBuffer, g.Index, g.Length));
                }
            }
            else
            {
                fieldsProcessor.SetInputField(idx++, new StringSlice(capture.BodyBuffer, capture.BodyIndex, capture.BodyLength));
            }

            threadLocalCallbackImpl.SetCurrentPosition(capture.BeginPosition, capture.EndPosition);

            IMessage ret;

            ret = fieldsProcessor.MakeMessage(threadLocalCallbackImpl, makeMessageFlags);

            ret.SetRawText(StringSlice.Concat(capture.MessageHeaderSlice, capture.MessageBodySlice).Trim());

            return(ret);
        }
        protected static MakeMessageFlags ParserFlagsToMakeMessageFlags(MessagesParserFlag flags)
        {
            MakeMessageFlags ret = MakeMessageFlags.Default;

            if ((flags & MessagesParserFlag.HintMessageTimeIsNotNeeded) != 0)
            {
                ret |= MakeMessageFlags.HintIgnoreTime;
            }
            if ((flags & MessagesParserFlag.HintMessageContentIsNotNeeed) != 0)
            {
                ret |= (MakeMessageFlags.HintIgnoreBody | MakeMessageFlags.HintIgnoreEntryType
                        | MakeMessageFlags.HintIgnoreSeverity | MakeMessageFlags.HintIgnoreThread);
            }
            return(ret);
        }
Exemplo n.º 3
0
 IMessage IFieldsProcessor.MakeMessage(IMessagesBuilderCallback callback, MakeMessageFlags flags)
 {
     return(builder.MakeMessage(callback, flags));
 }
Exemplo n.º 4
0
 public override void ParserCreated(CreateParserParams p)
 {
     base.ParserCreated(p);
     flags = ParserFlagsToMakeMessageFlags(p.Flags);
 }
Exemplo n.º 5
0
 public abstract IMessage MakeMessage(IMessagesBuilderCallback callback, MakeMessageFlags flags);