本文整理汇总了C#中IGraphProcessingEnvironment.Matched方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphProcessingEnvironment.Matched方法的具体用法?C# IGraphProcessingEnvironment.Matched怎么用?C# IGraphProcessingEnvironment.Matched使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphProcessingEnvironment
的用法示例。
在下文中一共展示了IGraphProcessingEnvironment.Matched方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyImpl
protected override bool ApplyImpl(IGraphProcessingEnvironment procEnv)
{
if(!ChooseRandom)
{
bool res;
try
{
#if LOG_SEQUENCE_EXECUTION
procEnv.Recorder.WriteLine("Applying rule all " + GetRuleCallString(procEnv));
#endif
res = procEnv.ApplyRewrite(ParamBindings, -1, -1, Special, Test, Filters) > 0;
}
catch (NullReferenceException)
{
System.Console.Error.WriteLine("Null reference exception during rule execution (null parameter?): " + Symbol);
throw;
}
#if LOG_SEQUENCE_EXECUTION
if(res)
{
procEnv.Recorder.WriteLine("Matched/Applied " + Symbol);
procEnv.Recorder.Flush();
}
#endif
return res;
}
else
{
// TODO: Code duplication! Compare with BaseGraph.ApplyRewrite.
int curMaxMatches = procEnv.MaxMatches;
object[] parameters;
if(ParamBindings.ArgumentExpressions.Length > 0)
{
parameters = ParamBindings.Arguments;
for(int i = 0; i < ParamBindings.ArgumentExpressions.Length; i++)
{
if(ParamBindings.ArgumentExpressions[i] != null)
parameters[i] = ParamBindings.ArgumentExpressions[i].Evaluate(procEnv);
}
}
else parameters = null;
if(ParamBindings.Subgraph!=null)
procEnv.SwitchToSubgraph((IGraph)ParamBindings.Subgraph.GetVariableValue(procEnv));
#if DEBUGACTIONS || MATCHREWRITEDETAIL
procEnv.PerformanceInfo.StartLocal();
#endif
IMatches matches;
try
{
matches = ParamBindings.Action.Match(procEnv, curMaxMatches, parameters);
for(int i = 0; i < Filters.Count; ++i)
ParamBindings.Action.Filter(procEnv, matches, Filters[i]);
}
catch (NullReferenceException)
{
System.Console.Error.WriteLine("Null reference exception during rule execution (null parameter?): " + Symbol);
throw;
}
#if DEBUGACTIONS || MATCHREWRITEDETAIL
procEnv.PerformanceInfo.StopMatch(); // total match time does NOT include listeners anymore
#endif
procEnv.PerformanceInfo.MatchesFound += matches.Count;
procEnv.Matched(matches, null, Special);
bool result = Rewrite(procEnv, matches, null);
if(ParamBindings.Subgraph != null)
procEnv.ReturnFromSubgraph();
return result;
}
}
示例2: 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;
}