private static IServiceBuilder AddRuntime(this IServiceBuilder builder) { var services = builder.Services; builder.Services.RegisterType(typeof(ClrServiceEntryFactory)).As(typeof(IClrServiceEntryFactory)).SingleInstance(); builder.Services.Register(provider => { #if NET var assemblys = AppDomain.CurrentDomain.GetAssemblies(); #else var assemblys = provider.ComponentRegistry.Registrations.SelectMany(x => x.Services) .OfType <IServiceWithType>() .Select(x => x.ServiceType.GetTypeInfo().Assembly); #endif var refAssemblies = builder.GetType().GetTypeInfo().Assembly.GetReferencedAssemblies().Select(p => p.FullName).ToList(); Regex regex = new Regex("Microsoft.\\w*|System.\\w*", RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.IgnoreCase); var types = assemblys.Where(i => i.IsDynamic == false && !refAssemblies.Contains(i.FullName) && !regex.IsMatch(i.FullName) ).SelectMany(i => i.ExportedTypes).ToArray(); return(new AttributeServiceEntryProvider(types, provider.Resolve <IClrServiceEntryFactory>(), provider.Resolve <ILogger <AttributeServiceEntryProvider> >())); }).As <IServiceEntryProvider>(); builder.Services.RegisterType(typeof(DefaultServiceEntryManager)).As(typeof(IServiceEntryManager)).SingleInstance(); return(builder); }