using AyCode.Core.Extensions;
using Mango.Nop.Core;
using Mango.Nop.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Nop.Core;
using Nop.Core.Caching;
using Nop.Core.Infrastructure;
using Nop.Data;
using Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
using Nop.Plugin.Misc.AuctionPlugin.Domains.EventConsumers;
using Nop.Plugin.Misc.AuctionPlugin.Hubs;
using Nop.Plugin.Misc.AuctionPlugin.Services;
using Nop.Services.Catalog;
using Nop.Services.Configuration;
using Nop.Services.Directory;
using Nop.Services.Localization;
using Nop.Services.Orders;
using Nop.Web.Framework;
using Nop.Web.Framework.Mvc.Routing;
namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
{
public class PluginNopStartup : INopStartup
{
public int Order => 999;
///
/// Add and configure any of the middleware
///
/// Collection of service descriptors
/// Configuration of the application
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.Configure(options =>
{
options.ViewLocationExpanders.Add(new ViewLocationExpander());
});
services.AddSingleton();
services.AddSingleton();
services.AddSignalR(hubOptions =>
{
hubOptions.ClientTimeoutInterval = TimeSpan.FromMinutes(20);
hubOptions.KeepAliveInterval = TimeSpan.FromMinutes(10);
});
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped(); //TODO: ez mi? - J.
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddHostedService();
}
///
/// Configure the using of added middleware
///
/// Builder for configuring an application's request pipeline
public void Configure(IApplicationBuilder application)
{
SerializeObjectExtensions.Options.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
SerializeObjectExtensions.Options.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
SerializeObjectExtensions.Options.NullValueHandling = NullValueHandling.Ignore;
SerializeObjectExtensions.Options.ContractResolver = new CamelCasePropertyNamesContractResolver();
application.UseEndpoints(endpoints =>
{
endpoints.MapHub("/auctionhub");
});
application.UseCors(options => {
options.AllowAnyMethod().AllowAnyHeader().AllowCredentials().SetIsOriginAllowed((hosts) => true);
});
}
}
}