protected override NodeMatchResult HandleRemoteNode <T>(MatchNodeArg <T> args) { // prepare pattern for remote partial search Pattern pattern = this.pattern.Copy(); pattern.CurrentNode = args.NodeToMatch.Id; pattern.CurrentPatternNodeName = args.PatternNode.Name; this.State = PartialMatchState.Pending; IPartialMatchResult result = null; using (MatcherMetric.RegisterWaitTime("partial remote match")) { result = Framework.BeginFindPartialMatch(args.RemotePartitionId, pattern); result.Wait(); } bool matched = result.MatchedPattern.GetMatchedNodes().Count() > pattern.GetMatchedNodes().Count; Pattern remotePattern = (Pattern)result.MatchedPattern; this.pattern.Merge(remotePattern); this.State = PartialMatchState.Running; return(new NodeMatchResult(matched, remotePattern.MatchedFullSubpattern)); }
protected override void Start() { if (State != PartialMatchState.ReadyToStart) { logger.Warn("Tried to start and already started matcher."); return; } this.State = PartialMatchState.Running; if (cts.Token.IsCancellationRequested) { logger.Warn("Cancelled before start."); return; } if (TryMatchPerson(this.person)) { logger.Info("Match found: {0}", this.person.FullName); OnMatchFound(); this.State = PartialMatchState.MatchFound; } else { OnMatchNotFound(); this.State = PartialMatchState.MatchNotFound; } this.signal.Set(); }
public PartialMatch(Person person, IMatcherFramework framework, IModel model) : base(framework) { this.person = person; this.State = PartialMatchState.ReadyToStart; this.model = model; }
public void Cancel() { this.cts.Cancel(); this.State = PartialMatchState.Cancelled; }