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


C# IMethodInfo.HasAttribute方法代码示例

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


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

示例1: EnumerateTestCommands

        public IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo testMethod) {
            foreach (var testCommand in _classCommand.EnumerateTestCommands(testMethod)) {
                if (testMethod.HasAttribute(typeof(FullTrustAttribute))
                    || testCommand is PartialTrustCommand) {
                    yield return testCommand;
                    continue;
                }

                yield return new PartialTrustCommand(testCommand);
            }
        }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:11,代码来源:PartialTrustClassCommand.cs

示例2: ValidateRequirements

        private bool ValidateRequirements(IMethodInfo method)
        {
            if (method.HasAttribute(typeof(RuntimeTestAttribute)))
            {
                RuntimeTestAttribute attr = method.GetCustomAttributes(typeof(RuntimeTestAttribute)).First().GetInstance<RuntimeTestAttribute>();
                if (!(RuntimeTestAttribute.RuntimeTestsEnabled || Debugger.IsAttached))
                {
                    this.Skip = String.Format("Runtime tests are not enabled on this test environment. To enable runtime tests set the environment variable '{0}'=true or run the tests under a debugger.", RuntimeTestAttribute.RuntimeTestsEnabledEnvironmentVariable);
                    return false;
                }
                else if (!(attr.NonPrivileged || UacUtilities.IsProcessElevated))
                {
                    this.Skip = String.Format("The runtime test '{0}' requires that the test process be elevated.", method.Name);
                    return false;
                }
            }
            else if (method.HasAttribute(typeof(Is64BitSpecificTestAttribute)) && !Is64BitSpecificTestAttribute.Is64BitOperatingSystem)
            {
                this.Skip = "64-bit specific tests are not enabled on 32-bit machines.";
                return false;
            }

            return true;
        }
开发者ID:zooba,项目名称:wix3,代码行数:24,代码来源:NamedFactAttribute.cs

示例3: IsTest

 public static bool IsTest(IMethodInfo method)
 {
     return !method.IsAbstract &&
             method.HasAttribute(typeof(FactAttribute));
 }
开发者ID:paulecoyote,项目名称:xunit,代码行数:5,代码来源:MethodUtility.cs

示例4: HasTraits

 public static bool HasTraits(IMethodInfo method)
 {
     return method.HasAttribute(typeof(TraitAttribute))
         || method.Class.HasAttribute(typeof(TraitAttribute));
 }
开发者ID:paulecoyote,项目名称:xunit,代码行数:5,代码来源:MethodUtility.cs

示例5: IsSpec

 private static bool IsSpec(IMethodInfo testMethod)
 {
     return testMethod.HasAttribute(typeof(SpecForAttribute));
 }
开发者ID:lynchjames,项目名称:ScotAlt.Net-Pex-QuickCheck,代码行数:4,代码来源:Alchemist.cs

示例6: IsVerifyMethod

 private static bool IsVerifyMethod(IMethodInfo testMethod)
 {
     return testMethod.HasAttribute(typeof(FactAttribute));
 }
开发者ID:lynchjames,项目名称:ScotAlt.Net-Pex-QuickCheck,代码行数:4,代码来源:Alchemist.cs

示例7: IsTestMethod

 public bool IsTestMethod(IMethodInfo testMethod)
 {
     return testMethod.HasAttribute(typeof(FactAttribute));
 }
开发者ID:lynchjames,项目名称:ScotAlt.Net-Pex-QuickCheck,代码行数:4,代码来源:Alchemist.cs

示例8: IsTestMethod

        public bool IsTestMethod(IMethodInfo testMethod)
        {
            // The ObservationAttribute is really not even required; we could just say any void-returning public
            // method is a test method (or you could say it has to start with "should").

            return testMethod.HasAttribute(typeof(ObservationAttribute));
        }
开发者ID:chrisortman,项目名称:coulda,代码行数:7,代码来源:SpecificationBaseRunner.cs

示例9: IsTest

        /// <summary>
        /// Determines whether a method is a test method. A test method must be decorated
        /// with the <see cref="FactAttribute"/> (or derived class) and must not be abstract.
        /// </summary>
        /// <param name="method">The method to be inspected</param>
        /// <returns>True if the method is a test method; false, otherwise</returns>
        public static bool IsTest(IMethodInfo method)
        {
            Guard.ArgumentNotNull("method", method);

            return !method.IsAbstract &&
                    method.HasAttribute(typeof(FactAttribute));
        }
开发者ID:johnkg,项目名称:xunit,代码行数:13,代码来源:MethodUtility.cs

示例10: HasTraits

        /// <summary>
        /// Determines whether a test method has traits.
        /// </summary>
        /// <param name="method">The method to be inspected</param>
        /// <returns>True if the method has traits; false, otherwise</returns>
        public static bool HasTraits(IMethodInfo method)
        {
            Guard.ArgumentNotNull("method", method);

            return method.HasAttribute(typeof(TraitAttribute))
                || method.Class.HasAttribute(typeof(TraitAttribute));
        }
开发者ID:johnkg,项目名称:xunit,代码行数:12,代码来源:MethodUtility.cs


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