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


C# RuleDispatcher.Dispatch方法代码示例

本文整理汇总了C#中RuleDispatcher.Dispatch方法的典型用法代码示例。如果您正苦于以下问题:C# RuleDispatcher.Dispatch方法的具体用法?C# RuleDispatcher.Dispatch怎么用?C# RuleDispatcher.Dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RuleDispatcher的用法示例。


在下文中一共展示了RuleDispatcher.Dispatch方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test

        public void Test()
        {
            // Create the cache and the dispatcher.
            List<MethodInfo> methods = new List<MethodInfo>();
            methods.AddRange(m_good);
            methods.AddRange(m_bad);
            methods.AddRange(m_used);

            TypeDefinition baseType = Assembly.MainModule.Types[GetType().FullName];		// some of the tests require an externally visible type
            AssemblyCache cache = new AssemblyCache(Assembly, baseType, methods);
            RuleDispatcher dispatcher = new RuleDispatcher();

            // Create the rule.
            Rule rule = OnCreate(cache, this);		// note that dispatcher will keep the rule from being GCed
            rule.Register(dispatcher);

            // Test the good methods.
            foreach (MethodInfo method in m_good)
            {
                m_failed = false;
                dispatcher.Dispatch(method.Method);
                dispatcher.Dispatch(method);

                if (m_failed)
                    Assert.Fail(string.Format("{0} should have passed", method.Method));
            }

            // Test the bad methods.
            foreach (MethodInfo method in m_bad)
            {
                m_failed = false;
                dispatcher.Dispatch(method.Method);
                dispatcher.Dispatch(method);

                if (!m_failed)
                    Assert.Fail(string.Format("{0} should have failed", method.Method));
            }
        }
开发者ID:dbremner,项目名称:smokey,代码行数:38,代码来源:MethodTest.cs

示例2: DoRunTest

        private void DoRunTest(Rule rule, List<TypeDefinition> types, AssemblyCache cache)
        {
            RuleDispatcher dispatcher = new RuleDispatcher();
            rule.Register(dispatcher);
            m_failed = false;

            dispatcher.Dispatch(new BeginTesting());
            dispatcher.Dispatch(Assembly);

            dispatcher.Dispatch(new BeginTypes());
            foreach (TypeDefinition t in types)
                dispatcher.Dispatch(t);
            dispatcher.Dispatch(new EndTypes());

            foreach (MethodInfo info in cache.Methods)
            {
                dispatcher.Dispatch(info);
            }

            dispatcher.DispatchCallGraph();
            dispatcher.Dispatch(new EndTesting());
        }
开发者ID:dbremner,项目名称:smokey,代码行数:22,代码来源:AssemblyTest.cs

示例3: DoVisit

        private void DoVisit(RuleDispatcher dispatcher, TypeDefinition type)
        {
            dispatcher.Dispatch(type);

            // Some rules consider all the methods in a type. These rules cannot be tested
            // with a MethodTest so we'll visit methods here in order to be able to unit
            // test those rules.
            dispatcher.Dispatch(new BeginMethods(type));
            foreach (MethodDefinition method in type.Constructors)
            {
                var minfo = new Smokey.Framework.Support.MethodInfo(type, method);
                dispatcher.Dispatch(minfo);
            }
            foreach (MethodDefinition method in type.Methods)
            {
                var minfo = new Smokey.Framework.Support.MethodInfo(type, method);
                dispatcher.Dispatch(minfo);
            }
            dispatcher.Dispatch(new EndMethods(type));
        }
开发者ID:dbremner,项目名称:smokey,代码行数:20,代码来源:TypeTest.cs


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