public static IEnumerable <Type> LoadAllTypeConfigurators(Assembly assembly, IBenchmarkOutput output = null) { using (var loader = AssemblyRuntimeLoader.WrapAssembly(assembly, output)) { return(LoadAllTypeConfigurators(loader)); } }
/// <summary> /// Finds a matching <see cref="IMeasurementConfigurator{T}"/> type for a given type of <see cref="MeasurementAttribute"/> /// </summary> /// <param name="measurementType">A type of <see cref="MeasurementAttribute"/></param> /// <param name="specificAssembly"> /// Optional parameter. If an <see cref="Assembly"/> is provided, we limit our search /// for <see cref="IMeasurementConfigurator{T}"/> definitions to just that target assembly. /// </param> /// <returns>A corresponding <see cref="IMeasurementConfigurator{T}"/> type</returns> public Type GetConfiguratorTypeForMeasurement(Type measurementType, IAssemblyLoader specificAssembly = null) { ValidateTypeIsMeasurementAttribute(measurementType); // served up the cached version if we already have it if (_measurementConfiguratorTypes.ContainsKey(measurementType)) { return(_measurementConfiguratorTypes[measurementType]); } using (specificAssembly = specificAssembly ?? AssemblyRuntimeLoader.WrapAssembly(measurementType.GetAssembly(), Output)) { // search for a match var match = FindBestMatchingConfiguratorForMeasurement(measurementType, LoadAllTypeConfigurators(specificAssembly)); // cache the result _measurementConfiguratorTypes[measurementType] = match; return(match); } }