public static IEnumerable <Type> SafeGetTypes(this _Assembly assembly) { if (assembly == null) { throw new ArgumentNullException(nameof(assembly)); } try { return(assembly.GetTypes()); } catch (ReflectionTypeLoadException ex) { if (IgnoreExceptions) { return(new List <Type>()); } var builder = new StringBuilder(); foreach (var exception in ex.LoaderExceptions) { builder.AppendLine(exception.Message); } throw new InvalidOperationException(builder.ToString()); } }
/// <summary> /// Gets all testable methods that are not inside a testable class /// </summary> public static IEnumerable <MethodInfo> GetUnattachedTestMethods(this _Assembly assembly) { return(assembly .GetTypes() .Where(type => !type.IsTestable()) .SelectMany(type => type.GetTestMethods())); }
/// <summary> /// Gets the enumerator. /// </summary> /// <returns></returns> public IEnumerator <Type> GetEnumerator() { foreach (var type in _assembly.GetTypes()) { yield return(type); } }
public void LoadFromAssembly(_Assembly assembly) { if (assembly == null) { throw new ArgumentNullException("assembly"); } _types.AddRange(assembly.GetTypes()); }
/// <summary> /// Extracts the controller types in the specified assembly. /// </summary> /// <param name="assemblyToCrawl">Assembly to crawl for Controllers.</param> /// <returns>Enumeration of controllers discovered. If none found, will return an empty enumeration.</returns> public static IEnumerable <Type> GetControllerTypes(_Assembly assemblyToCrawl) { if (assemblyToCrawl == null) { throw new ArgumentNullException(nameof(assemblyToCrawl)); } var controllerTypes = assemblyToCrawl.GetTypes().Where(t => t.Inherits <Controller>() && t.IsPublic && !t.IsAbstract && ControllerNameRegex.IsMatch(t.Name)); return(controllerTypes); }
static Type FindType(_Assembly assembly, string namespaceName, string typeName) { if(namespaceName != "?" && typeName != "?") { var typeFullName = typeName; if(namespaceName != "") typeFullName = namespaceName + "." + typeName; return assembly.GetType(typeFullName); } var types = assembly.GetTypes(); return types.FirstOrDefault(t => IsMatch(t, namespaceName, typeName)); }
public void LoadFlushedCode(_Assembly assembly) { ArgumentUtility.CheckNotNull("assembly", assembly); var typePipeAttribute = (TypePipeAssemblyAttribute)assembly.GetCustomAttributes(typeof(TypePipeAssemblyAttribute), inherit: false).SingleOrDefault(); if (typePipeAttribute == null) { throw new ArgumentException("The specified assembly was not generated by the pipeline.", "assembly"); } if (typePipeAttribute.ParticipantConfigurationID != _typeAssembler.ParticipantConfigurationID) { var message = string.Format( "The specified assembly was generated with a different participant configuration: '{0}'.", typePipeAttribute.ParticipantConfigurationID); throw new ArgumentException(message, "assembly"); } _typeCache.LoadTypes(assembly.GetTypes()); }
/// <summary> /// Gets the enumerator. /// </summary> /// <returns></returns> public IEnumerator <Type> GetEnumerator() { Type[] types = new Type[] {}; try { types = _assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { //log and swallow everything that might go wrong here... Logger.Debug(m => m("Failed to get types " + ex.LoaderExceptions), ex); } catch (Exception ex) { //log and swallow everything that might go wrong here... Logger.Debug(m => m("Failed to get types "), ex); } foreach (Type type in types) { yield return(type); } }
/// <summary> /// Gets all testable classes (types) within the assembly /// </summary> public static IEnumerable <Type> GetTestClasses(this _Assembly assembly) { return(assembly .GetTypes() .Where(type => type.IsTestable())); }
void AddAssembly(_Assembly assembly) { lock (_lockObject) { if (!_assemblies.Contains(assembly, comparer) && !_assemblyUtility.IsAssemblyDynamic(assembly)) { _assemblies.Add(assembly); if (assembly.FullName.Contains("Web")) { var i = 0; i++; } _contractToImplementorsMap.Feed(assembly.GetTypes()); SpecifyRules(assembly); ReapplyFilter(); } } }