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


C# Assembly.GetAttributes方法代码示例

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


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

示例1: IsInternalToDynamicProxy

		/// <summary>
		///   Determines whether this assembly has internals visible to dynamic proxy.
		/// </summary>
		/// <param name = "asm">The assembly to inspect.</param>
		public bool IsInternalToDynamicProxy(Assembly asm)
		{
			using (var locker = internalsToDynProxyLock.ForReadingUpgradeable())
			{
				if (internalsToDynProxy.ContainsKey(asm))
				{
					return internalsToDynProxy[asm];
				}

				locker.Upgrade();

				if (internalsToDynProxy.ContainsKey(asm))
				{
					return internalsToDynProxy[asm];
				}

                var internalsVisibleTo = asm.GetAttributes<InternalsVisibleToAttribute>();
                var found = internalsVisibleTo.Any(attr => {
                            var parts = attr.AssemblyName.Split(',');
                            return parts.Length > 0
                                && (parts[0] == this.moduleScope.StrongAssemblyName
                                    || parts[0] == this.moduleScope.WeakAssemblyName);
                        });

				internalsToDynProxy.Add(asm, found);
				return found;
			}
		}
开发者ID:BiBongNet,项目名称:JustMockLite,代码行数:32,代码来源:InternalsUtil.cs

示例2: GetAssemblyConfiguration

        // ReSharper restore SuggestBaseTypeForParameter
        // ReSharper disable SuggestBaseTypeForParameter
        internal static Result<string> GetAssemblyConfiguration(Assembly callingAssembly)
        {
            var attributes = callingAssembly
                .GetAttributes<AssemblyConfigurationAttribute>(true);

            if (attributes.Length == 0)
                return Result<string>.CreateError("Attribute is not present");
            return Result.CreateSuccess(attributes[0].Configuration);
        }
开发者ID:pocheptsov,项目名称:lokad-shared-libraries,代码行数:11,代码来源:AssemblyUtil.cs

示例3: GetActionsFromAttributeProvider

        public static ITestAction[] GetActionsFromAttributeProvider(Assembly attributeProvider)
        {
            if (attributeProvider == null)
                return new ITestAction[0];

            var actions = attributeProvider.GetAttributes<ITestAction>().ToList();
            actions.Sort(SortByTargetDescending);

            return actions.ToArray();
        }
开发者ID:ChrisMaddock,项目名称:nunit,代码行数:10,代码来源:ActionsHelper.cs

示例4: AddCompression

        /// <summary>
        ///     Add a compression stream to the library.  Zlib is the default.
        /// </summary>
        /// <param name="a">
        ///     The assembly containing the stream definition.
        /// </param>
        public static void AddCompression(Assembly a)
        {
            Log.Debug("Loading compression algorithms from {Assembly}", a.FullName);

            IEnumerable<CompressionAttribute> tags = a.GetAttributes<CompressionAttribute>();
            foreach (CompressionAttribute tag in tags)
            {
                Log.Debug("Loading algorithm {Algorithm}", tag.Algorithm);
                RegisteredItems.Add(tag.Algorithm, tag.ClassType);
            }
        }
开发者ID:nairaner,项目名称:xmpp,代码行数:17,代码来源:CompressionRegistry.cs

示例5: AddCompression

        /// <summary>
        /// Add a compression stream to the library.  Zlib is the default.
        /// </summary>
        /// <param name="a">
        /// The assembly containing the stream definition.
        /// </param>
        public static void AddCompression(Assembly a)
        {
            Logger.DebugFormat(typeof(CompressionRegistry), "Adding assembly {0}", a.FullName);

            var tags = a.GetAttributes<CompressionAttribute>();
            foreach (var tag in tags)
            {
                Logger.DebugFormat(typeof(CompressionRegistry), "Adding {0}", tag.Algorithm);
                RegisteredItems.Add(tag.Algorithm, tag.ClassType);
            }
        }
开发者ID:sstraus,项目名称:xmpp,代码行数:17,代码来源:CompressionRegistry.cs

示例6: ApplyAttributesToTest

 /// <summary>
 /// Modify a newly constructed test by applying any of NUnit's common
 /// attributes, based on a supplied ICustomAttributeProvider, which is
 /// usually the reflection element from which the test was constructed,
 /// but may not be in some instances. The attributes retrieved are 
 /// saved for use in subsequent operations.
 /// </summary>
 /// <param name="provider">An object deriving from MemberInfo</param>
 public void ApplyAttributesToTest(Assembly provider)
 {
     foreach (IApplyToTest iApply in provider.GetAttributes<IApplyToTest>())
         iApply.ApplyToTest(this);
 }
开发者ID:nunit,项目名称:nunit,代码行数:13,代码来源:Test.cs


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