/// <summary>Registers the type mappings with the Unity container.</summary> /// <param name="services"></param> /// <param name="configuration"></param> /// <param name="container">The unity container to configure.</param> /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks> public static void AddNakedObjects(this IServiceCollection services, IConfiguration configuration) { // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements. // container.LoadConfiguration(); //Standard configuration ParallelConfig.RegisterStandardFacetFactories(services); ParallelConfig.RegisterCoreSingletonTypes(services); ParallelConfig.RegisterCoreScopedTypes(services); // add custom factories ConfigHelpers.RegisterFacetFactory(typeof(AWNotNavigableFacetFactoryParallel), services, 1000); ConfigHelpers.RegisterFacetFactory(typeof(AWNotCountedAnnotationFacetFactoryParallel), services, 1001); // config services.AddSingleton <IReflectorConfiguration>(p => NakedObjectsRunSettings.ReflectorConfig()); services.AddSingleton <IEntityObjectStoreConfiguration>(p => NakedObjectsRunSettings.EntityObjectStoreConfig(configuration)); // frameworkFacade services.AddTransient <IOidTranslator, OidTranslatorSlashSeparatedTypeAndIds>(); services.AddTransient <IOidStrategy, EntityOidStrategy>(); services.AddTransient <IStringHasher, InvariantStringHasher>(); services.AddTransient <IFrameworkFacade, FrameworkFacade>(); //Externals services.AddScoped <IPrincipal>(p => p.GetService <IHttpContextAccessor>().HttpContext.User); }
/// <summary>Registers the type mappings with the Unity container.</summary> /// <param name="services"></param> /// <param name="configuration"></param> /// <param name="container">The unity container to configure.</param> /// <remarks> /// There is no need to register concrete types such as controllers or API controllers (unless you want to /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered. /// </remarks> public static void AddNakedObjects(this IServiceCollection services, IConfiguration configuration) { // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements. // container.LoadConfiguration(); //Standard configuration ParallelConfig.RegisterStandardFacetFactories(services); ParallelConfig.RegisterCoreSingletonTypes(services); ParallelConfig.RegisterCoreScopedTypes(services); // config services.AddSingleton <IReflectorConfiguration>(p => NakedObjectsRunSettings.ReflectorConfig()); services.AddSingleton <IEntityObjectStoreConfiguration>(p => NakedObjectsRunSettings.EntityObjectStoreConfig(configuration)); services.AddScoped <IBatchRunner, BatchRunner>(); //Externals services.AddScoped(p => Thread.CurrentPrincipal); }
public static void AddNakedObjects(this IServiceCollection services, IConfiguration configuration) { ParallelConfig.RegisterStandardFacetFactories(services); ParallelConfig.RegisterCoreSingletonTypes(services); ParallelConfig.RegisterCoreScopedTypes(services); // config services.AddSingleton <IReflectorConfiguration>(p => NakedObjectsRunSettings.ReflectorConfig()); services.AddSingleton <IEntityObjectStoreConfiguration>(p => NakedObjectsRunSettings.EntityObjectStoreConfig(configuration)); // frameworkFacade services.AddTransient <IOidTranslator, OidTranslatorSlashSeparatedTypeAndIds>(); services.AddTransient <IOidStrategy, EntityOidStrategy>(); services.AddTransient <IStringHasher, InvariantStringHasher>(); services.AddTransient <IFrameworkFacade, FrameworkFacade>(); //Externals services.AddScoped <IPrincipal>(p => p.GetService <IHttpContextAccessor>().HttpContext.User); }
private static void AddNakedCoreFramework(this IServiceCollection services, NakedCoreOptions options) { ParallelConfig.RegisterCoreSingletonTypes(services); ParallelConfig.RegisterCoreScopedTypes(services); if (options.AuthorizationConfiguration is not null) { services.AddSingleton(options.AuthorizationConfiguration); services.AddSingleton <IFacetDecorator, AuthorizationManager>(); } if (options.AuditConfiguration is not null) { services.AddSingleton(options.AuditConfiguration); services.AddSingleton <IFacetDecorator, AuditManager>(); } if (options.ProfileConfiguration is not null) { services.AddSingleton(options.ProfileConfiguration); services.AddSingleton <IFacetDecorator, ProfileManager>(); } services.AddSingleton <ICoreConfiguration>(p => CoreConfig(options)); // frameworkFacade services.AddTransient <IOidTranslator, OidTranslatorSlashSeparatedTypeAndIds>(); services.AddTransient <IOidStrategy, EntityOidStrategy>(); services.AddTransient <IStringHasher, InvariantStringHasher>(); services.AddTransient <IFrameworkFacade, FrameworkFacade>(); //Externals services.AddScoped <IPrincipal>(p => p.GetService <IHttpContextAccessor>().HttpContext.User); }