private static void ThrowIfMarkerInterfaceIsRegistered(PluginGraph graph) { if (graph.HasFamily<IMarkerInterface>()) { throw new InvalidOperationException("Populate should only be called once per container."); } }
// ASP.NET expects registered services to be considered when selecting a ctor, SM doesn't by default. public ConstructorInfo Find(Type pluggedType, DependencyCollection dependencies, PluginGraph graph) => pluggedType.GetTypeInfo() .DeclaredConstructors .Select(ctor => new { Constructor = ctor, Parameters = ctor.GetParameters() }) .Where(x => x.Parameters.All(param => graph.HasFamily(param.ParameterType))) .OrderByDescending(x => x.Parameters.Length) .Select(x => x.Constructor) .FirstOrDefault();