当前位置: 首页>>代码示例>>C#>>正文


C# IGraphProcessingEnvironment.Matched方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:jblomer,项目名称:GrGen.NET,代码行数:77,代码来源:Sequence.cs

示例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;
        }
开发者ID:jblomer,项目名称:GrGen.NET,代码行数:17,代码来源:Sequence.cs


注:本文中的IGraphProcessingEnvironment.Matched方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。