Exemplo n.º 1
0
        public void TestConnection()
        {
            CaptureList captureList = new CaptureList();

            captureList.PopulateAllCaptures(false);
            Assert.IsTrue(captureList.list.Count > 0);
        }
Exemplo n.º 2
0
        public void CatpureXml()
        {
            CaptureList captureList = new CaptureList();

            captureList.PopulateAllCaptures(false);
            XmlDocument doc = captureList.SerialiseMe();

            Assert.IsTrue(doc.OuterXml.Count() > 0);
        }
Exemplo n.º 3
0
        public void TestCaptureMovementExtraction()
        {
            CaptureList captureList = new CaptureList();

            captureList.PopulateAllCaptures(false);
            captureList.PopulateMovement();

            int nMovements = (from c in captureList.list
                              select c.movement.Count).Sum();

            Assert.IsTrue(nMovements > 0);
        }
Exemplo n.º 4
0
        internal override MatchResult BeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList CapturedList)
        {
            tracker.DebugStart(this);
            //we don't want to capture so send in a null
            var r = ContainedElement.BeginProcessMatch(tracker, eventenum, null);

            if (tracker.DebugEnabled)
            {
                tracker.SaveDBGResult(this, r);
            }
            return(r);
        }
Exemplo n.º 5
0
        internal override MatchResult IsMatch(IChronologicalEvent chronevent, Tracker Tracker, CaptureList CapturedList)
        {
            var a = ContainedElement.IsMatch(chronevent, Tracker, CapturedList);

            return(a);
        }
Exemplo n.º 6
0
 internal override MatchResult BeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList CapturedList)
 {
     foreach (var item in Statements)
     {
         var r = item.BeginProcessMatch(tracker, eventenum, CapturedList);
         if (r.Is_Match())
         {
             return(r);
         }
     }
     return(MatchResult.None);
 }
Exemplo n.º 7
0
 internal override MatchResult IsMatch(IChronologicalEvent chronevent, Tracker Tracker, CaptureList CapturedList)
 {
     //should not be called , processed by the prcoessmatfhes function
     throw new NotImplementedException();
 }
Exemplo n.º 8
0
        //public override ElementBase ReturnParseTreeFromExistingElement(ElementBase ExisitngElement)
        //{
        //    //for now I am the top element inthe chain so add it to me and return myself
        //    AddContainedElement(ExisitngElement);
        //    return this;
        //}

        internal override MatchResult SubBeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList CapturedList)
        {
            //first lets check the statebag to see if we are in there yet
            var sbag = GetQuantifierState(tracker);

            if (!sbag.MatchCount.HasValue)
            {
                sbag.MatchCount = new Nullable <int>(0);
                tracker.SetMyStateBag(this, sbag);
            }

            //Pass the event along to the contained element and get its result
            var subRes = ContainedElement.BeginProcessMatch(tracker, eventenum, sbag.CaptureList);

            MatchResult tres = IsMatchResult.IsNotMatch;

            if (QuantifierSymbol == '+')
            {
                tres = HandlePlus(sbag.MatchCount, subRes);
            }

            if (QuantifierSymbol == '*')
            {
                tres = HandleStar(sbag.MatchCount, subRes);
            }

            if (QuantifierSymbol == '?')
            {
                tres = HandleQuestionMark(sbag.MatchCount, subRes);
            }

            //if its the end (either a match or not) , then remove our bag state
            if (!tres.Is_Continue())
            {
                if (tres.Is_Match())
                {
                    //specEventStream.EndApplyAll();
                    if (CapturedList != null)
                    {
                        CapturedList.AddRange(sbag.CaptureList.Items);
                    }
                }
                tracker.RemoveMyStateBag(this);
            }
            else
            {
                //if its a continue then increment the bagstate
                sbag.MatchCount = sbag.MatchCount.Value + 1;
                tracker.SetMyStateBag(this, sbag);
            }



            //return to the tracker the result
            if (subRes.Is_Forward())
            {
                tres = tres | MatchResult.Forward;
            }
            return(tres);
        }
 internal abstract MatchResult SubBeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList capturedList);
Exemplo n.º 10
0
        internal override MatchResult BeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList CapturedList)
        {
            //since the loop has already advanced the event for the next item , also mark it as a forward so
            //that when the parent loop continues processing it should resuse the current item
            //var spec = eventenum.CreateSpeculator();
            var g = base.BeginProcessMatch(tracker, eventenum, CapturedList) | MatchResult.Forward;

            //if (!g.Is_Ended())
            //{
            //    g = g   ;
            //}
            //else
            //{
            //    spec.EndDiscardAll();
            //}
            return(g);
        }
Exemplo n.º 11
0
        internal virtual MatchResult BeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList CapturedList)
        {
            tracker.DebugStart(this, eventenum.Current);
            //for almost all selectors this is going to be a driect call to is match
            var res = IsMatch(eventenum.Current, tracker, CapturedList);

            if (res.Is_Capture() & CapturedList != null)
            {
                CapturedList.Add(eventenum.Current);
            }

            if (tracker.DebugEnabled)
            {
                tracker.SaveDBGResult(this, res);
            }
            return(res);
        }
Exemplo n.º 12
0
 /// <summary>
 /// matches the event against the full element and determines if the event
 /// satifies the element criteria,
 /// </summary>
 /// <param name="chronevent"></param>
 /// <returns></returns>
 internal abstract MatchResult IsMatch(IChronologicalEvent chronevent, Tracker Tracker, CaptureList CapturedList);
Exemplo n.º 13
0
        internal override MatchResult BeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList CapturedList)
        {
            //can't neagte a null - if null event then return no match
            if (eventenum.Current == null)
            {
                return(IsMatchResult.IsNotMatch);
            }

            var a = ContainedElement.BeginProcessMatch(tracker, eventenum, null);

            if (a.Is_Match())
            {
                a = IsMatchResult.IsNotMatch;
            }
            else
            {
                CapturedList.Add(eventenum.Current);
                a = IsMatchResult.IsMatch;
            }

            return(a);
        }
Exemplo n.º 14
0
        internal override MatchResult SubBeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList CapturedList)
        {
            if (eventenum.Current == null)
            {
                return(MatchResult.None);
            }
            MatchResult tres = MatchResult.None;
            var         sbag = GetQuantifierState(tracker);

            if (!sbag.MatchCount.HasValue)
            {
                sbag.MatchCount = new Nullable <int>(0);
                tracker.SetMyStateBag(this, sbag);
            }
            var specEventStream = eventenum;//eventenum.CreateSpeculator();

            do
            {
                MatchResult subRes = MatchResult.None;

                subRes = ContainedElement.BeginProcessMatch(tracker, eventenum, sbag.CaptureList);
                if (!subRes.Is_Match())
                {
                    //if we matched our minimun we can make a final decisison if it did not match
                    if (sbag.MatchCount.Value >= MinOccours)
                    {
                        tres = MatchResult.Match | MatchResult.Forward;
                    }
                    else//if we have not yet matched our minimun then we just need to continue
                    {
                        tres = MatchResult.Continue | MatchResult.Capture;
                    }
                }


                //if we did match
                if (subRes.Is_Match())
                {
                    //if we reached the max then return a match
                    if (sbag.MatchCount.Value + 1 == MaxOccours)
                    {
                        tres = IsMatchResult.IsMatch;
                    }
                    else
                    {
                        //if we matched at least min then mark as match and contineu
                        if (sbag.MatchCount.Value + 1 >= MinOccours)
                        {
                            tres = MatchResult.Match | MatchResult.Continue | MatchResult.Capture;
                        }
                        else
                        {
                            //just continue matching
                            //if the subres has a forward , then don't capture , just relay the forward
                            if (subRes.Is_Forward())
                            {
                                tres = MatchResult.Continue | MatchResult.Forward;
                            }
                            else
                            {
                                tres = MatchResult.Continue | MatchResult.Capture;
                            }
                        }
                    }
                }

                //if its the end (either a match or not) , then remove our bag state
                if (!tres.Is_Continue())
                {
                    tracker.RemoveMyStateBag(this);
                }
                else
                {
                    //if its a continue then increment the bagstate
                    sbag.MatchCount++;
                    tracker.SetMyStateBag(this, sbag);
                }

                if (subRes.Is_Forward())
                {
                    tres = tres | MatchResult.Forward;
                }

                //if this is a match without a continue then grab the commmit the speculator
                //and add the spculative captures to the tracker captures
                if (tres.Is_Match() && !tres.Is_Continue())
                {
                    //specEventStream.EndApplyAll();
                    if (CapturedList != null)
                    {
                        CapturedList.AddRange(sbag.CaptureList.Items);
                    }
                    return(tres);
                }

                //if this is not a match and not a continue then rollback the speculator and return the result
                if (!tres.Is_Match() && !tres.Is_Continue())
                {
                    //specEventStream.EndDiscardAll();
                    return(tres);
                }
                //its a continue so allow the loop to continue
            }while (
                specEventStream.MoveNextIfNotForward(tres));
            //if we are here it means that we ran out of events so we got to deal with that
            if (tres.Is_Match())
            {
                if (CapturedList != null)
                {
                    CapturedList.AddRange(sbag.CaptureList.Items);
                }
            }
            //remove the continue if its there
            if (tres.Is_Continue())
            {
                var mask = ~MatchResult.Continue;
                tres = tres & mask;
            }
            return(tres);
        }
Exemplo n.º 15
0
 internal override MatchResult IsMatch(IChronologicalEvent chronevent, Tracker Tracker, CaptureList CapturedList)
 {
     if (chronevent == null)
     {
         return(MatchResult.None);
     }
     if (IsRegexMatch(chronevent.EventName))
     {
         return(Processor.IsMatchResult.IsMatch);
     }
     return(Processor.IsMatchResult.IsNotMatch);
 }
Exemplo n.º 16
0
        internal override MatchResult BeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList CapturedList)
        {
            tracker.DebugStart(this, eventenum.Current);
            // we need to override this becasue the base class does event capturing
            // we handle capturing internally
            var b = this.SubBeginProcessMatch(tracker, eventenum, CapturedList);

            if (tracker.DebugEnabled)
            {
                tracker.SaveDBGResult(this, b);
            }
            return(b);
        }
Exemplo n.º 17
0
 internal override MatchResult IsMatch(IChronologicalEvent chronevent, Tracker Tracker, CaptureList CapturedList)
 {
     //nulls are always no matches
     if (chronevent == null)
     {
         return(MatchResult.None);
     }
     if (IsDotWildcard)
     {
         return(IsMatchResult.IsMatch);
     }
     return((string.Compare(chronevent.EventName, this.EventName, true) == 0)
         ? Processor.IsMatchResult.IsMatch : Processor.IsMatchResult.IsNotMatch);
 }
Exemplo n.º 18
0
 internal override MatchResult IsMatch(IChronologicalEvent chronevent, Tracker Tracker, CaptureList CapturedList)
 {
     throw new NotImplementedException();
 }
        //basic and container
        internal override MatchResult BeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList CapturedList)
        {
            //container elements run thru all of the statements and apply the matches
            //when we enter here the eventenum should already be pointng at the correct event
            tracker.DebugStart(this);
            //tracker.dbgMsgs.Add(this.ToString());
            var movenextres      = true;
            var myStatementsEnum = Statements.GetEnumerator();

            //move to t he first statement
            myStatementsEnum.MoveNext();

            MatchResult res = MatchResult.None;

            while (myStatementsEnum.Current != null)
            {
                //transfer responsibility to each statement , the simple ones will just return their matches
                //the more advanced ones will take over the processing

                //if eventnum is empty

                res = myStatementsEnum.Current.BeginProcessMatch(tracker, eventenum, CapturedList);
                //if the child did not requst to forward then move the event
                if (!res.Is_Forward())
                {
                    eventenum.MoveNext();
                }
                //if i don't match - and the element is not saying continue with me , in other words there is no hope for
                //me to match not now and not in the future

                if (!res.Is_Match() && !res.Is_Continue())
                {
                    if (tracker.DebugEnabled)
                    {
                        tracker.SaveDBGResult(this, res);
                    }
                    if (!res.Is_Forward())
                    {
                    }
                    return(res);
                }
                //if the child element didn't ask to contine with its elf then move next element
                if (!res.Is_Continue())
                {
                    myStatementsEnum.MoveNext();
                }



                //if i already matched but there aren't any more statements in the events then just return a match
                if (res.Is_Match() && eventenum.Current == null)
                {
                    //return res;
                }
            }

            if (tracker.DebugEnabled)
            {
                tracker.SaveDBGResult(this, res);
            }
            //if we got here then everythign matched
            if (eventenum.Current == null)
            {
                res = res | MatchResult.Ended;
            }
            return(res);
        }