예제 #1
0
        /// <summary></summary>
        protected virtual bool Resolve(IRoot root, IRuleTemplateList ruleTemplateList, string passName)
        {
            BuildInferenceSourceList Context = new BuildInferenceSourceList(ruleTemplateList);
            IWalkCallbacks <BuildInferenceSourceList> Callbacks = new WalkCallbacks <BuildInferenceSourceList>()
            {
                HandlerNode = ListAllSources, IsRecursive = true, BlockSubstitution = CreateBlockSubstitution()
            };
            IList <IClass> ClassList = root.ClassList;

            foreach (IClass Class in ClassList)
            {
                NodeTreeWalk.Walk <BuildInferenceSourceList>(Class, Callbacks, Context);
            }

            IList <ISource> SourceList = Context.SourceList;
            InferenceEngine Engine     = new InferenceEngine(ruleTemplateList, SourceList, ClassList, true, InferenceRetries);

            bool Success = Engine.Solve(ErrorList, passName);

            Debug.Assert(Success || !ErrorList.IsEmpty);
            return(Success);
        }
예제 #2
0
        /// <summary></summary>
        protected virtual bool ListAllSources(BaseNode.INode node, BaseNode.INode parentNode, string propertyName, IWalkCallbacks <BuildInferenceSourceList> callbacks, BuildInferenceSourceList context)
        {
            ISource Source = node as ISource;

            Debug.Assert(Source != null);

            Source.Reset(context.RuleTemplateList);

#if COVERAGE
            Debug.Assert(!Source.IsResolved(context.RuleTemplateList));
            Debug.Assert(Source.ToString().Length > 0);
#endif

            foreach (IRuleTemplate RuleTemplate in context.RuleTemplateList)
            {
                if (RuleTemplate.NodeType.IsAssignableFrom(Source.GetType()))
                {
                    context.SourceList.Add(Source);
                    break;
                }
            }

            return(true);
        }