本文整理汇总了C#中IGraphProcessingEnvironment.EnteringSequence方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphProcessingEnvironment.EnteringSequence方法的具体用法?C# IGraphProcessingEnvironment.EnteringSequence怎么用?C# IGraphProcessingEnvironment.EnteringSequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphProcessingEnvironment
的用法示例。
在下文中一共展示了IGraphProcessingEnvironment.EnteringSequence方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public override bool Apply(SequenceInvocationParameterBindings sequenceInvocation,
IGraphProcessingEnvironment procEnv)
{
// If this sequence definition is currently executed
// we must copy it and use the copy in its place
// to prevent state corruption.
if(executionState == SequenceExecutionState.Underway)
{
return ApplyCopy(sequenceInvocation, procEnv);
}
procEnv.EnteringSequence(this);
executionState = SequenceExecutionState.Underway;
#if LOG_SEQUENCE_EXECUTION
procEnv.Recorder.WriteLine("Before executing sequence definition " + Id + ": " + Symbol);
#endif
bool res = ApplyImpl(sequenceInvocation, procEnv);
#if LOG_SEQUENCE_EXECUTION
procEnv.Recorder.WriteLine("After executing sequence definition " + Id + ": " + Symbol + " result " + res);
#endif
executionState = res ? SequenceExecutionState.Success : SequenceExecutionState.Fail;
procEnv.EndOfIteration(false, this);
procEnv.ExitingSequence(this);
ResetExecutionState(); // state is shown by call, we don't exist any more for the debugger
return res;
}
示例2: ApplyImpl
protected override bool ApplyImpl(IGraphProcessingEnvironment procEnv)
{
bool res = true;
// first get all matches of the rule
object[] parameters;
if(Rule.ParamBindings.ArgumentExpressions.Length > 0)
{
parameters = Rule.ParamBindings.Arguments;
for(int j = 0; j < Rule.ParamBindings.ArgumentExpressions.Length; j++)
{
if(Rule.ParamBindings.ArgumentExpressions[j] != null)
parameters[j] = Rule.ParamBindings.ArgumentExpressions[j].Evaluate(procEnv);
}
}
else parameters = null;
#if LOG_SEQUENCE_EXECUTION
procEnv.Recorder.WriteLine("Matching for rule " + Rule.GetRuleCallString(procEnv));
#endif
#if DEBUGACTIONS || MATCHREWRITEDETAIL
procEnv.PerformanceInfo.StartLocal();
#endif
IMatches matches = Rule.ParamBindings.Action.Match(procEnv, procEnv.MaxMatches, parameters);
for(int i=0; i<Rule.Filters.Count; ++i)
Rule.ParamBindings.Action.Filter(procEnv, matches, Rule.Filters[i]);
#if DEBUGACTIONS || MATCHREWRITEDETAIL
procEnv.PerformanceInfo.StopMatch(); // total match time does NOT include listeners anymore
#endif
procEnv.PerformanceInfo.MatchesFound += matches.Count;
if(matches.Count == 0)
{
procEnv.EndOfIteration(false, this);
Rule.executionState = SequenceExecutionState.Fail;
return res;
}
#if LOG_SEQUENCE_EXECUTION
procEnv.Recorder.WriteLine("Rule " + Rule.GetRuleCallString(procEnv) + " matched " + matches.Count + " times");
#endif
// the rule might be called again in the sequence, overwriting the matches object of the action
// normally it's safe to assume the rule is not called again until its matches were processed,
// allowing for the one matches object memory optimization, but here we must clone to prevent bad side effect
// TODO: optimization; if it's ensured the sequence doesn't call this action again, we can omit this, requires call analysis
matches = matches.Clone();
// apply the sequence for every match found
bool first = true;
foreach(IMatch match in matches)
{
if(!first) procEnv.EndOfIteration(true, this);
Var.SetVariableValue(match, procEnv);
#if LOG_SEQUENCE_EXECUTION
procEnv.Recorder.WriteLine("Iterating match: " + MatchPrinter.ToString(match, procEnv.Graph, ""));
#endif
procEnv.EnteringSequence(Rule);
Rule.executionState = SequenceExecutionState.Underway;
procEnv.Matched(matches, match, Rule.Special);
Rule.executionState = SequenceExecutionState.Success;
procEnv.ExitingSequence(Rule);
// rule matching simulated so it can be shown in the debugger, now execute the sequence
Seq.ResetExecutionState();
res &= Seq.Apply(procEnv);
first = false;
}
procEnv.EndOfIteration(false, this);
return res;
}
示例3: ApplyRule
protected bool ApplyRule(SequenceRuleCall rule, IGraphProcessingEnvironment procEnv, IMatches matches, IMatch match)
{
bool result;
procEnv.EnteringSequence(rule);
rule.executionState = SequenceExecutionState.Underway;
#if LOG_SEQUENCE_EXECUTION
procEnv.Recorder.WriteLine("Before executing sequence " + rule.Id + ": " + rule.Symbol);
#endif
procEnv.Matched(matches, null, rule.Special);
result = rule.Rewrite(procEnv, matches, match);
#if LOG_SEQUENCE_EXECUTION
procEnv.Recorder.WriteLine("After executing sequence " + rule.Id + ": " + rule.Symbol + " result " + result);
#endif
rule.executionState = result ? SequenceExecutionState.Success : SequenceExecutionState.Fail;
procEnv.ExitingSequence(rule);
return result;
}