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


C# IAttributeInfo.GetConstructorArguments方法代码示例

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


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

示例1: GetTraits

 /// <summary>
 /// Gets the trait values from the Category attribute.
 /// </summary>
 /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
 /// <returns>The trait values.</returns>
 public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
 {
     TargetFrameworkMonikers platform = (TargetFrameworkMonikers)traitAttribute.GetConstructorArguments().First();
     if (platform.HasFlag(TargetFrameworkMonikers.Net45))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet45Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net451))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet451Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net452))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet452Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net46))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet46Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net461))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet461Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net462))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet462Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net463))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet463Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Netcore50))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcore50Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Netcore50aot))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcore50aotTest);
     if (platform.HasFlag(TargetFrameworkMonikers.Netcoreapp1_0))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_0Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Netcoreapp1_1))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_1Test);
 }
开发者ID:roncain,项目名称:buildtools,代码行数:31,代码来源:SkipOnTargetFrameworkDiscoverer.cs

示例2: Discover

 public override IEnumerable<IXunitTestCase> Discover(
     ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
 {
     string[] conditionMemberNames = factAttribute.GetConstructorArguments().FirstOrDefault() as string[];
     IEnumerable<IXunitTestCase> testCases = base.Discover(discoveryOptions, testMethod, factAttribute);
     return ConditionalTestDiscoverer.Discover(discoveryOptions, _diagnosticMessageSink, testMethod, testCases, conditionMemberNames);
 }
开发者ID:dsgouda,项目名称:buildtools,代码行数:7,代码来源:ConditionalFactDiscoverer.cs

示例3: Discover

        public override IEnumerable<IXunitTestCase> Discover(
            ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
        {
            MethodInfo testMethodInfo = testMethod.Method.ToRuntimeMethod();

            string conditionMemberName = factAttribute.GetConstructorArguments().FirstOrDefault() as string;
            MethodInfo conditionMethodInfo;
            if (conditionMemberName == null ||
                (conditionMethodInfo = LookupConditionalMethod(testMethodInfo.DeclaringType, conditionMemberName)) == null)
            {
                return new[] {
                    new ExecutionErrorTestCase(
                        _diagnosticMessageSink,
                        discoveryOptions.MethodDisplayOrDefault(),
                        testMethod,
                        GetFailedLookupString(conditionMemberName))
                };
            }

            IEnumerable<IXunitTestCase> testCases = base.Discover(discoveryOptions, testMethod, factAttribute);
            if ((bool)conditionMethodInfo.Invoke(null, null))
            {
                return testCases;
            }
            else
            {
                string skippedReason = "\"" + conditionMemberName + "\" returned false.";
                return testCases.Select(tc => new SkippedTestCase(tc, skippedReason));
            }
        }
开发者ID:jango2015,项目名称:buildtools,代码行数:30,代码来源:ConditionalFactDiscoverer.cs

示例4: GetMetrics

 public IEnumerable<PerformanceMetricInfo> GetMetrics(IAttributeInfo metricAttribute)
 {
     if (_profileSource != -1)
     {
         var interval = (int)(metricAttribute.GetConstructorArguments().FirstOrDefault() ?? DefaultInterval);
         yield return new InstructionsRetiredMetric(interval, _profileSource);
     }
 }
开发者ID:davmason,项目名称:xunit-performance,代码行数:8,代码来源:InstructionsRetiredMetricDiscoverer.cs

示例5: GetTraits

 /// <summary>
 /// Gets the trait values from the trait attribute.
 /// </summary>
 /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
 /// <returns>The trait values</returns>
 public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
 {
     IEnumerator<object> enumerator = traitAttribute.GetConstructorArguments().GetEnumerator();
     while (enumerator.MoveNext())
     {
         yield return new KeyValuePair<string, string>(enumerator.Current.ToString(), "");
     }
 }
开发者ID:Gajendra-Bahakar,项目名称:azure-storage-net,代码行数:13,代码来源:TestCategoryDiscoverer.cs

示例6: GetTraits

 public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
 {
     var array = (CompilerFeature[])traitAttribute.GetConstructorArguments().Single();
     foreach (var feature in array)
     { 
         var value = feature.ToString();
         yield return new KeyValuePair<string, string>("Compiler", value);
     }
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:ComilerTraitDiscoverer.cs

示例7: Discover

        public IEnumerable<IXunitTestCase> Discover(ITestMethod testMethod, IAttributeInfo factAttribute)
        {
            var ctorArgs = factAttribute.GetConstructorArguments().ToArray();
            var cultures = Reflector.ConvertArguments(ctorArgs, new[] { typeof(string[]) }).Cast<string[]>().Single();

            if (cultures == null || cultures.Length == 0)
                cultures = new[] { "en-US", "fr-FR" };

            return cultures.Select(culture => new CulturedXunitTestCase(testMethod, culture)).ToList();
        }
开发者ID:ansarisamer,项目名称:xunit,代码行数:10,代码来源:CulturedFactAttributeDiscoverer.cs

示例8: Discover

        public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
        {
            var ctorArgs = factAttribute.GetConstructorArguments().ToArray();
            var cultures = Reflector.ConvertArguments(ctorArgs, new[] { typeof(string[]) }).Cast<string[]>().Single();

            if (cultures == null || cultures.Length == 0)
                cultures = new[] { "en-US", "fr-FR" };

            return cultures.Select(culture => new CulturedXunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, culture)).ToList();
        }
开发者ID:modai888,项目名称:xunit,代码行数:10,代码来源:CulturedFactAttributeDiscoverer.cs

示例9: GetSkippableExceptionNames

        internal static string[] GetSkippableExceptionNames(IAttributeInfo factAttribute)
        {
            var firstArgument = (object[])factAttribute.GetConstructorArguments().FirstOrDefault();
            var skippingExceptions = firstArgument?.Cast<Type>().ToArray() ?? new Type[0];
            Array.Resize(ref skippingExceptions, skippingExceptions.Length + 1);
            skippingExceptions[skippingExceptions.Length - 1] = typeof(SkipException);

            var skippingExceptionNames = skippingExceptions.Select(ex => ex.FullName).ToArray();
            return skippingExceptionNames;
        }
开发者ID:AArnott,项目名称:Xunit.SkippableFact,代码行数:10,代码来源:SkippableFactDiscoverer.cs

示例10: GetTraits

 /// <summary>
 /// Gets the trait values from the Category attribute.
 /// </summary>
 /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
 /// <returns>The trait values.</returns>
 public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
 {
     IEnumerable<object> ctorArgs = traitAttribute.GetConstructorArguments();
     foreach (var arg in ctorArgs)
     {
         string issue = arg.ToString();
         yield return new KeyValuePair<string, string>("category", "failing");
         yield return new KeyValuePair<string, string>("ActiveIssue", issue);
         break;
     }
 }
开发者ID:svcgany1,项目名称:corefx,代码行数:16,代码来源:ActiveIssueDiscoverer.cs

示例11: GetTraits

 /// <summary>
 /// Gets the trait values from the Category attribute.
 /// </summary>
 /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
 /// <returns>The trait values.</returns>
 public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
 {
     PlatformID platform = (PlatformID)traitAttribute.GetConstructorArguments().First();
     if (!platform.HasFlag(PlatformID.Windows))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonWindowsTest);
     if (!platform.HasFlag(PlatformID.Linux))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonLinuxTest);
     if (!platform.HasFlag(PlatformID.OSX))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonOSXTest);
     if (!platform.HasFlag(PlatformID.FreeBSD))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonFreeBSDTest);
 }
开发者ID:lishibo,项目名称:buildtools,代码行数:17,代码来源:PlatformSpecificDiscoverer.cs

示例12: GetData

        /// <inheritdoc/>
        public virtual IEnumerable<object[]> GetData(IAttributeInfo dataAttribute, IMethodInfo testMethod)
        {
            // The data from GetConstructorArguments does not maintain its original form (in particular, collections
            // end up as generic IEnumerable<T>). So we end up needing to call .ToArray() on the enumerable so that
            // we can restore the correct argument type from InlineDataAttribute.
            //
            // In addition, [InlineData(null)] gets translated into passing a null array, not a single array with a null
            // value in it, which is why the null coalesce operator is required (this is covered by the acceptance test
            // in Xunit2TheoryAcceptanceTests.InlineDataTests.SingleNullValuesWork).

            var args = (IEnumerable<object>)dataAttribute.GetConstructorArguments().Single() ?? new object[] { null };
            return new[] { args.ToArray() };
        }
开发者ID:modai888,项目名称:xunit,代码行数:14,代码来源:InlineDataDiscoverer.cs

示例13: GetTraits

        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
        {
            IEnumerable<object> ctorArgs = traitAttribute.GetConstructorArguments();
            Debug.Assert(ctorArgs.Count() >= 2);

            string issue = ctorArgs.First().ToString();
            PlatformID platforms = (PlatformID)ctorArgs.Last();
            if ((platforms.HasFlag(PlatformID.FreeBSD) && Interop.IsFreeBSD) ||
                (platforms.HasFlag(PlatformID.Linux) && Interop.IsLinux) ||
                (platforms.HasFlag(PlatformID.OSX) && Interop.IsOSX) ||
                (platforms.HasFlag(PlatformID.Windows) && Interop.IsWindows))
            {
                yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.Failing);
                yield return new KeyValuePair<string, string>(XunitConstants.ActiveIssue, issue);
            }
        }
开发者ID:tmat,项目名称:buildtools,代码行数:21,代码来源:ActiveIssueDiscoverer.cs

示例14: GetTraits

        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
        {
            IEnumerable<object> ctorArgs = traitAttribute.GetConstructorArguments();
            Debug.Assert(ctorArgs.Count() >= 2);

            string issue = ctorArgs.First().ToString();
            TestPlatforms platforms = (TestPlatforms)ctorArgs.Last();
            if ((platforms.HasFlag(TestPlatforms.FreeBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) ||
                (platforms.HasFlag(TestPlatforms.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) ||
                (platforms.HasFlag(TestPlatforms.NetBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD"))) ||
                (platforms.HasFlag(TestPlatforms.OSX) && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) ||
                (platforms.HasFlag(TestPlatforms.Windows) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)))
            {
                yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.Failing);
                yield return new KeyValuePair<string, string>(XunitConstants.ActiveIssue, issue);
            }

        }
开发者ID:roncain,项目名称:buildtools,代码行数:23,代码来源:ActiveIssueDiscoverer.cs

示例15: Discover

        public override IEnumerable<IXunitTestCase> Discover(
            ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute)
        {
            MethodInfo testMethodInfo = testMethod.Method.ToRuntimeMethod();

            string conditionMemberName = theoryAttribute.GetConstructorArguments().FirstOrDefault() as string;
            Type declaringType = testMethodInfo.DeclaringType;
            string[] symbols = conditionMemberName.Split('.');

            if (symbols.Length == 2)
            {
                conditionMemberName = symbols[1];
                ITypeInfo type = testMethod.TestClass.Class.Assembly.GetTypes(false).Where(t => t.Name.Contains(symbols[0])).FirstOrDefault();
                if (type != null)
                {
                    declaringType = type.ToRuntimeType();
                }
            }

            MethodInfo conditionMethodInfo;
            if (conditionMemberName == null ||
                (conditionMethodInfo = ConditionalFactDiscoverer.LookupConditionalMethod(declaringType, conditionMemberName)) == null)
            {
                return new[] {
                    new ExecutionErrorTestCase(
                        _diagnosticMessageSink,
                        discoveryOptions.MethodDisplayOrDefault(),
                        testMethod,
                        ConditionalFactDiscoverer.GetFailedLookupString(conditionMemberName))
                };
            }

            IEnumerable<IXunitTestCase> testCases = base.Discover(discoveryOptions, testMethod, theoryAttribute);
            if ((bool)conditionMethodInfo.Invoke(null, null))
            {
                return testCases;
            }
            else
            {
                string skippedReason = "\"" + conditionMemberName + "\" returned false.";
                return testCases.Select(tc => new SkippedTestCase(tc, skippedReason));
            }
        }
开发者ID:karajas,项目名称:buildtools,代码行数:43,代码来源:ConditionalTheoryDiscoverer.cs


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