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


C# Assembly.IsDefined方法代码示例

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


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

示例1: Explore

        IEnumerable<Assembly> Explore(Assembly assembly)
        {
            if (!assembly.IsDefined(typeof(IoCAttribute)))
                yield break;

            yield return assembly;
            foreach (var a in assembly
                .GetReferencedAssemblies()
                .Select(an => Assembly.Load(an))
                .SelectMany(ra => Explore(ra)))
                yield return a;
        }
开发者ID:bcjobs,项目名称:infra,代码行数:12,代码来源:ReferencedAssemblies.cs

示例2: GetAttribute

        /// <overloads>
        /// Gets the specified object attributes
        /// </overloads>
        /// <summary>
        /// Gets the specified object attributes for assembly as specified by type
        /// </summary>
        /// <param name="attributeType">The attribute Type for which the custom attributes are to be returned.</param>
        /// <param name="assembly">the assembly in which the specified attribute is defined</param>
        /// <returns>Attribute as Object or null if not found.</returns>
        public static object GetAttribute(Type attributeType, Assembly assembly)
        {
            if (attributeType == null)
            {
                throw new ArgumentNullException("attributeType");
            }

            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

            if (assembly.IsDefined(attributeType, false))
            {
                object[] attributes = assembly.GetCustomAttributes(attributeType, false);

                return attributes[0];
            }

            return null;
        }
开发者ID:yonglehou,项目名称:ToolRepository,代码行数:30,代码来源:ReflectionExt.cs

示例3: IsDefined

		public static bool IsDefined (Assembly element, Type attributeType, bool inherit)
		{
			CheckParameters (element, attributeType);

			return element.IsDefined (attributeType, inherit);
		}
开发者ID:valsavva,项目名称:mono,代码行数:6,代码来源:Attribute.cs

示例4: ComputeNamespaces

  		void ComputeNamespaces (Assembly assembly, Type extensionType)
  		{
			bool contains_extension_methods = extensionType != null && assembly.IsDefined (extensionType, false);
 
 			if (get_namespaces_method != null) {
  				string [] namespaces = (string []) get_namespaces_method.Invoke (assembly, null);
  				foreach (string ns in namespaces)
 					RegisterNamespace (ns);

				if (!contains_extension_methods)
					return;
  			}

 			foreach (Type t in assembly.GetTypes ()) {
 				if ((t.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute &&
 					contains_extension_methods && t.IsDefined (extensionType, false))
 					RegisterExtensionMethodClass (t);

				if (get_namespaces_method == null)
					RegisterNamespace (t.Namespace);
 			}
  		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:22,代码来源:namespace.cs

示例5: IsDefined

        public static bool IsDefined (Assembly element, Type attributeType, bool inherit)
        {
            // Returns true is a custom attribute subclass of attributeType class/interface with no inheritance walk
            if (element == null)
                throw new ArgumentNullException(nameof(element));

            if (attributeType == null)
                throw new ArgumentNullException(nameof(attributeType));

            if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
                throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
            Contract.EndContractBlock();

            return element.IsDefined(attributeType, false);
        }
开发者ID:Clockwork-Muse,项目名称:coreclr,代码行数:15,代码来源:Attribute.cs

示例6: IsDefined

 public static bool IsDefined(Assembly element, Type attributeType, bool inherit)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     if (attributeType == null)
     {
         throw new ArgumentNullException("attributeType");
     }
     if (!attributeType.IsSubclassOf(typeof(Attribute)) && (attributeType != typeof(Attribute)))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
     }
     return element.IsDefined(attributeType, false);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:Attribute.cs

示例7: IsSchemaAttributePresent

 internal static bool IsSchemaAttributePresent(Assembly assembly)
 {
     return assembly.IsDefined(typeof(EdmSchemaAttribute), false /*inherit*/);
 }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:4,代码来源:ObjectItemAttributeAssemblyLoader.cs

示例8: IsViewAssembly

 public virtual bool IsViewAssembly(Assembly assembly)
 {
     return assembly.IsDefined(typeof(EntityViewGenerationAttribute), inherit: false);
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:4,代码来源:ViewAssemblyChecker.cs

示例9: HasAPTCABit

 private static bool HasAPTCABit(Assembly assembly)
 {
   return assembly.IsDefined(typeof (AllowPartiallyTrustedCallersAttribute), false);
 }
开发者ID:consumentor,项目名称:Server,代码行数:4,代码来源:HttpRuntime.cs

示例10: GetExtensionMethodNamespaces

 public static void GetExtensionMethodNamespaces(Assembly assembly, List<string> namespaces)
 {
     if (assembly.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), false))
     {
         foreach (Type tp in assembly.GetTypes())
         {
             // Check if type has defined "ExtensionAttribute"
             if (tp.IsSealed && !tp.IsGenericType && !tp.IsNested &&
                 tp.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), false))
             {
                 if (!namespaces.Contains(tp.Namespace))
                 {
                     namespaces.Add(tp.Namespace);
                 }
             }
         }
     }
 }
开发者ID:kooboo-jifeng,项目名称:SharpTAL,代码行数:18,代码来源:Utils.cs

示例11: CanParticipateInStartup

 private bool CanParticipateInStartup(Assembly assembly)
 {
     return assembly.IsDefined(typeof(ParticipateInStartupAttribute), false)
            || _filters.Any(f => f(assembly));
 }
开发者ID:happyframework,项目名称:Happy.Startup,代码行数:5,代码来源:DefaultStartupService.cs


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