Machine.Specifications.Explorers.AssemblyExplorer.FindSpecificationSupplementsIn C# (CSharp) Method

FindSpecificationSupplementsIn() public method

public FindSpecificationSupplementsIn ( Assembly assembly ) : IEnumerable
assembly System.Reflection.Assembly
return IEnumerable
        public IEnumerable<ISupplementSpecificationResults> FindSpecificationSupplementsIn(Assembly assembly)
        {
            return assembly.GetExportedTypes()
              .Where(x => x.GetInterfaces().Contains(typeof(ISupplementSpecificationResults)))
              .Select(x => (ISupplementSpecificationResults)Activator.CreateInstance(x));
        }

Usage Example

    public void Run(Assembly assembly, IEnumerable<Context> contexts)
    {
      var hasExecutableSpecifications = contexts.Any(x => x.HasExecutableSpecifications);

      var explorer = new AssemblyExplorer();
      var globalCleanups = explorer.FindAssemblyWideContextCleanupsIn(assembly).ToList();
      var specificationSupplements = explorer.FindSpecificationSupplementsIn(assembly).ToList();

      try
      {
        if (hasExecutableSpecifications)
        {
          _assemblyStart(assembly);
        }

        foreach (var context in contexts)
        {
          RunContext(context, globalCleanups, specificationSupplements);
        }
      }
      catch (Exception err)
      {
        _listener.OnFatalError(new ExceptionResult(err));
      }
      finally
      {
        if (hasExecutableSpecifications)
        {
          _assemblyEnd(assembly);
        }
      }
    }
All Usage Examples Of Machine.Specifications.Explorers.AssemblyExplorer::FindSpecificationSupplementsIn