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


C# IAssemblyInfo.GetCustomAttributes方法代码示例

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


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

示例1: GetTestFrameworkType

        static Type GetTestFrameworkType(IAssemblyInfo testAssembly, IMessageSink diagnosticMessageSink)
        {
            try
            {
                var testFrameworkAttr = testAssembly.GetCustomAttributes(typeof(ITestFrameworkAttribute)).FirstOrDefault();
                if (testFrameworkAttr != null)
                {
                    var discovererAttr = testFrameworkAttr.GetCustomAttributes(typeof(TestFrameworkDiscovererAttribute)).FirstOrDefault();
                    if (discovererAttr != null)
                    {
                        var discoverer = ExtensibilityPointFactory.GetTestFrameworkTypeDiscoverer(diagnosticMessageSink, discovererAttr);
                        if (discoverer != null)
                            return discoverer.GetTestFrameworkType(testFrameworkAttr);

                        var ctorArgs = discovererAttr.GetConstructorArguments().ToArray();
                        diagnosticMessageSink.OnMessage(new DiagnosticMessage($"Unable to create custom test framework discoverer type '{ctorArgs[1]}, {ctorArgs[0]}'"));
                    }
                    else
                    {
                        diagnosticMessageSink.OnMessage(new DiagnosticMessage("Assembly-level test framework attribute was not decorated with [TestFrameworkDiscoverer]"));
                    }
                }
            }
            catch (Exception ex)
            {
                diagnosticMessageSink.OnMessage(new DiagnosticMessage($"Exception thrown during test framework discoverer construction: {ex.Unwrap()}"));
            }

            return typeof(XunitTestFramework);
        }
开发者ID:modai888,项目名称:xunit,代码行数:30,代码来源:TestFrameworkProxy.cs

示例2: GetAssemblyLoaders

 public static IList<AssemblyLoaderAttribute> GetAssemblyLoaders(IAssemblyInfo assemblyInfo) {
     return assemblyInfo.GetCustomAttributes(typeof(AssemblyLoaderAttribute))
         .OfType<IReflectionAttributeInfo>()
         .Select(ai => ai.Attribute)
         .OfType<AssemblyLoaderAttribute>()
         .ToList();
 }
开发者ID:Microsoft,项目名称:RTVS,代码行数:7,代码来源:AssemblyLoaderAttribute.cs

示例3: SpecThisTestFrameworkDiscoverer

 public SpecThisTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo, ISourceInformationProvider sourceProvider, IMessageSink diagnosticMessageSink, IXunitTestCollectionFactory collectionFactory = null)
     : base(assemblyInfo, sourceProvider, diagnosticMessageSink)
 {
     IAttributeInfo collectionBehaviorAttribute = assemblyInfo.GetCustomAttributes(typeof(CollectionBehaviorAttribute)).SingleOrDefault<IAttributeInfo>();
     bool flag = collectionBehaviorAttribute != null && collectionBehaviorAttribute.GetNamedArgument<bool>("DisableTestParallelization");
     string configurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
     TestAssembly testAssembly = new TestAssembly(assemblyInfo, configurationFile);
     this.TestCollectionFactory = collectionFactory ?? ExtensibilityPointFactory.GetXunitTestCollectionFactory(diagnosticMessageSink, collectionBehaviorAttribute, (ITestAssembly)testAssembly);
     this.TestFrameworkDisplayName = string.Format("{0} [{1}, {2}]", XunitTestFrameworkDiscoverer.DisplayName, this.TestCollectionFactory.DisplayName, flag ? "non-parallel" : "parallel");
 }
开发者ID:BrunoJuchli,项目名称:SpecThisXUnitSpike,代码行数:10,代码来源:SpecThisTestFrameworkDiscoverer.cs

示例4: EvaluateSkipConditions

        private string EvaluateSkipConditions(IAssemblyInfo assembly)
        {
            var reasons = assembly
                .GetCustomAttributes(typeof(ITestCondition))
                .OfType<ReflectionAttributeInfo>()
                .Select(attributeInfo => (ITestCondition)attributeInfo.Attribute)
                .Where(condition => !condition.IsMet)
                .Select(condition => condition.SkipReason)
                .ToList();

            return reasons.Count > 0 ? string.Join(Environment.NewLine, reasons) : null;
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:12,代码来源:ConditionalTestFrameworkExecutor.cs

示例5: XunitTestFrameworkDiscoverer

        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkDiscoverer"/> class.
        /// </summary>
        /// <param name="assemblyInfo">The test assembly.</param>
        /// <param name="sourceProvider">The source information provider.</param>
        /// <param name="collectionFactory">The test collection factory used to look up test collections.</param>
        /// <param name="messageAggregator">The message aggregator to receive environmental warnings from.</param>
        public XunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                            ISourceInformationProvider sourceProvider,
                                            IXunitTestCollectionFactory collectionFactory,
                                            IMessageAggregator messageAggregator)
            : base(assemblyInfo, sourceProvider, messageAggregator)
        {
            var collectionBehaviorAttribute = assemblyInfo.GetCustomAttributes(typeof(CollectionBehaviorAttribute)).SingleOrDefault();
            var disableParallelization = collectionBehaviorAttribute == null ? false : collectionBehaviorAttribute.GetNamedArgument<bool>("DisableTestParallelization");

            TestCollectionFactory = collectionFactory ?? GetTestCollectionFactory(this.AssemblyInfo, collectionBehaviorAttribute);
            TestFrameworkDisplayName = String.Format("{0} [{1}, {2}]",
                                                     DisplayName,
                                                     TestCollectionFactory.DisplayName,
                                                     disableParallelization ? "non-parallel" : "parallel");
        }
开发者ID:EurekaMu,项目名称:xunit,代码行数:22,代码来源:XunitTestFrameworkDiscoverer.cs

示例6: XunitTestFrameworkDiscoverer

        readonly Dictionary<Type, Type> discovererTypeCache = new Dictionary<Type, Type>(); // key is a Type that is or derives from FactAttribute

        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkDiscoverer"/> class.
        /// </summary>
        /// <param name="assemblyInfo">The test assembly.</param>
        /// <param name="sourceProvider">The source information provider.</param>
        /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
        /// <param name="collectionFactory">The test collection factory used to look up test collections.</param>
        public XunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                            ISourceInformationProvider sourceProvider,
                                            IMessageSink diagnosticMessageSink,
                                            IXunitTestCollectionFactory collectionFactory = null)
            : base(assemblyInfo, sourceProvider, diagnosticMessageSink)
        {
            var collectionBehaviorAttribute = assemblyInfo.GetCustomAttributes(typeof(CollectionBehaviorAttribute)).SingleOrDefault();
            var disableParallelization = collectionBehaviorAttribute != null && collectionBehaviorAttribute.GetNamedArgument<bool>("DisableTestParallelization");

            string config = null;
#if !PLATFORM_DOTNET
            config = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
#endif
            var testAssembly = new TestAssembly(assemblyInfo, config);

            TestCollectionFactory = collectionFactory ?? ExtensibilityPointFactory.GetXunitTestCollectionFactory(diagnosticMessageSink, collectionBehaviorAttribute, testAssembly);
            TestFrameworkDisplayName = $"{DisplayName} [{TestCollectionFactory.DisplayName}, {(disableParallelization ? "non-parallel" : "parallel")}]";
        }
开发者ID:commonsensesoftware,项目名称:xunit,代码行数:27,代码来源:XunitTestFrameworkDiscoverer.cs

示例7: XunitTestFrameworkExecutor

        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkExecutor"/> class.
        /// </summary>
        /// <param name="assemblyFileName">Path of the test assembly.</param>
        public XunitTestFrameworkExecutor(string assemblyFileName)
        {
            this.assemblyFileName = assemblyFileName;

            var assembly = Assembly.Load(AssemblyName.GetAssemblyName(assemblyFileName));
            assemblyInfo = Reflector.Wrap(assembly);

            var collectionBehaviorAttribute = assemblyInfo.GetCustomAttributes(typeof(CollectionBehaviorAttribute)).SingleOrDefault();
            if (collectionBehaviorAttribute != null)
                disableParallelization = collectionBehaviorAttribute.GetNamedArgument<bool>("DisableTestParallelization");

            var testCollectionFactory = XunitTestFrameworkDiscoverer.GetTestCollectionFactory(assemblyInfo, collectionBehaviorAttribute);
            displayName = String.Format("{0}-bit .NET {1} [{2}, {3}]",
                                        IntPtr.Size * 8,
                                        Environment.Version,
                                        testCollectionFactory.DisplayName,
                                        disableParallelization ? "non-parallel" : "parallel");
        }
开发者ID:JayBazuzi,项目名称:xunit,代码行数:22,代码来源:XunitTestFrameworkExecutor.cs

示例8: XunitTestFrameworkDiscoverer

        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkDiscoverer"/> class.
        /// </summary>
        /// <param name="assemblyInfo">The test assembly.</param>
        /// <param name="sourceProvider">The source information provider.</param>
        /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
        /// <param name="collectionFactory">The test collection factory used to look up test collections.</param>
        public XunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                            ISourceInformationProvider sourceProvider,
                                            IMessageSink diagnosticMessageSink,
                                            IXunitTestCollectionFactory collectionFactory = null)
            : base(assemblyInfo, sourceProvider, diagnosticMessageSink)
        {
            var collectionBehaviorAttribute = assemblyInfo.GetCustomAttributes(typeof(CollectionBehaviorAttribute)).SingleOrDefault();
            var disableParallelization = collectionBehaviorAttribute == null ? false : collectionBehaviorAttribute.GetNamedArgument<bool>("DisableTestParallelization");

            string config = null;
#if !WINDOWS_PHONE_APP && !WINDOWS_PHONE && !DNXCORE50
            config = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
#endif
            var testAssembly = new TestAssembly(assemblyInfo, config);

            TestCollectionFactory = collectionFactory ?? ExtensibilityPointFactory.GetXunitTestCollectionFactory(diagnosticMessageSink, collectionBehaviorAttribute, testAssembly);
            TestFrameworkDisplayName = string.Format("{0} [{1}, {2}]",
                                                     DisplayName,
                                                     TestCollectionFactory.DisplayName,
                                                     disableParallelization ? "non-parallel" : "parallel");
        }
开发者ID:ricardoshimoda,项目名称:xunit,代码行数:28,代码来源:XunitTestFrameworkDiscoverer.cs

示例9: TestFrameworkDiscoverer

        /// <summary>
        /// Initializes a new instance of the <see cref="XunitTestFrameworkDiscoverer"/> class.
        /// </summary>
        /// <param name="assemblyInfo">The test assembly.</param>
        /// <param name="sourceProvider">The source information provider.</param>
        /// <param name="messageAggregator">The message aggregator to receive environmental warnings from.</param>
        public TestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                       ISourceInformationProvider sourceProvider,
                                       IMessageAggregator messageAggregator)
        {
            Guard.ArgumentNotNull("assemblyInfo", assemblyInfo);
            Guard.ArgumentNotNull("sourceProvider", sourceProvider);

            Aggregator = messageAggregator ?? MessageAggregator.Instance;
            AssemblyInfo = assemblyInfo;
            DisposalTracker = new DisposalTracker();
            SourceProvider = sourceProvider;

            targetFramework = new Lazy<string>(() =>
            {
                string result = null;

                var attrib = AssemblyInfo.GetCustomAttributes(typeof(TargetFrameworkAttribute)).FirstOrDefault();
                if (attrib != null)
                    result = attrib.GetConstructorArguments().Cast<string>().First();

                return result ?? "";
            });
        }
开发者ID:ansarisamer,项目名称:xunit,代码行数:29,代码来源:TestFrameworkDiscoverer.cs

示例10: GetTestCollectionFactory

        static IXunitTestCollectionFactory GetTestCollectionFactory(IAssemblyInfo assemblyInfo)
        {
            var collectionBehavior = assemblyInfo.GetCustomAttributes(typeof(CollectionBehaviorAttribute)).SingleOrDefault();
            var factoryType = GetTestCollectionFactoryType(collectionBehavior);

            return (IXunitTestCollectionFactory)Activator.CreateInstance(factoryType, new[] { assemblyInfo });
        }
开发者ID:JoB70,项目名称:xunit,代码行数:7,代码来源:XunitTestFrameworkDiscoverer.cs


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