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; }
/// <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; }
public static bool IsDefined (Assembly element, Type attributeType, bool inherit) { CheckParameters (element, attributeType); return element.IsDefined (attributeType, inherit); }
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); } }
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); }
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); }
internal static bool IsSchemaAttributePresent(Assembly assembly) { return assembly.IsDefined(typeof(EdmSchemaAttribute), false /*inherit*/); }
public virtual bool IsViewAssembly(Assembly assembly) { return assembly.IsDefined(typeof(EntityViewGenerationAttribute), inherit: false); }
private static bool HasAPTCABit(Assembly assembly) { return assembly.IsDefined(typeof (AllowPartiallyTrustedCallersAttribute), false); }
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); } } } } }
private bool CanParticipateInStartup(Assembly assembly) { return assembly.IsDefined(typeof(ParticipateInStartupAttribute), false) || _filters.Any(f => f(assembly)); }