From bdf4f157320f6015d2c304ffd783c0a99285cfcb Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sat, 9 May 2026 22:21:26 +0330 Subject: [PATCH] last ... --- Startup.cs | 109 +++++------------------------------------------------ 1 file changed, 10 insertions(+), 99 deletions(-) diff --git a/Startup.cs b/Startup.cs index 5f214b8..5fcdc43 100644 --- a/Startup.cs +++ b/Startup.cs @@ -34,11 +34,15 @@ namespace xApi { public class Startup { + // public IConfiguration Configuration { get; } + private readonly XApiDatabaseDescriptor apiDatabaseDescriptor; public Startup(IConfiguration configuration) { + // Configuration = configuration; + apiDatabaseDescriptor = new XApiDatabaseDescriptor(); } public void ConfigureServices(IServiceCollection services) @@ -110,110 +114,17 @@ namespace xApi x.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }); - // - // Check Data Service ... - var dataServiceConfig = Configuration.GetXDataServiceConfiguration(); + // // + // // Check Data Service ... + // var dataServiceConfig = Configuration.GetXDataServiceConfiguration(); // // Check DataBase Registration ... services.AddXDatabase( + lifetime: lifeTime, configuration: Configuration, - descriptor: new XApiDatabaseDescriptor(), - lifetime: ServiceLifetime.Scoped + descriptor: apiDatabaseDescriptor ); - - // // - // // Register XPushService ... - // services.AddXPushService(Configuration); - // services.AddXPushHubProvider(lifeTime); - - // // - // // Register XIdentityService ... - // services.AddXIdentityService(Configuration, lifeTime); - - // // - // // Register DataService here ... - // #region Register xDataService ... - // // - // // Register IXDataServiceHelper ... - // services.AddSingleton(); - - // // - // // Prepare Db Options Builder based on Provider ... - // var providerType = Configuration.GetXDbProviderType(); - // switch (providerType) - // { - // // - // case XDbProviders.MySQL: - // case XDbProviders.SQLite: - // case XDbProviders.SQLServer: - // Action optionsBuilder = optionsBuilder = b => - // { - // b.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name); - // }; - - // // - // // Register xDataService on DI ... - // services.AddXDataService( - // Configuration, - // lifeTime, - // XDbProviderConfigurations.DEFAULT_CONNECTION_NAME, - // optionsBuilder - // ); - // break; - - // // - // case XDbProviders.MongoDB: - // // - // // Register xDataService on DI ... - // services.AddXDataService( - // Configuration, - // lifeTime, - // XDbProviderConfigurations.DEFAULT_CONNECTION_NAME - // ); - // break; - // } - // #endregion - - // // - // // Register GraphQL here ... - // #region Register xGraphQL ... - // // - // services.Configure(options => - // { - // options.AllowSynchronousIO = true; - // }); - - // // - // services.Configure(options => - // { - // options.AllowSynchronousIO = true; - // }); - - // // - // // Register XGraphQL Helper ... - // services.AddSingleton(); - - // // - // services.AddXGraphQL(options => - // { - // // - // options.EnableMetrics = true; - // options.UnhandledExceptionDelegate = context => - // { - // Console.WriteLine("XGraphQL Error: " + context.OriginalException.Message); - // }; - // }); - // #endregion - - // // - // // Register Services Module Providers here ... - // #region Register xServices ... - // services.AddXServices( - // lifeTime: lifeTime, - // configuration: Configuration - // ); - // #endregion } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) @@ -265,7 +176,7 @@ namespace xApi // // Use xDataService Middleware ... - // app.UseXDataService(); + app.UseXDatabase(apiDatabaseDescriptor); // // Using Services ...