using Volo.Abp.Modularity;
using Volo.Abp.Localization;
using JiShe.CollectBus.Localization;
using Volo.Abp.Domain;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Validation;
using Volo.Abp.Validation.Localization;
using Volo.Abp.VirtualFileSystem;
using JiShe.CollectBus.Interceptors;
using Microsoft.Extensions.DependencyInjection;

namespace JiShe.CollectBus;

[DependsOn(
    typeof(AbpValidationModule),
    typeof(AbpDddDomainSharedModule)
)]
public class CollectBusDomainSharedModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        Configure<AbpVirtualFileSystemOptions>(options =>
        {
            options.FileSets.AddEmbedded<CollectBusDomainSharedModule>();
        });

        Configure<AbpLocalizationOptions>(options =>
        {
            options.Resources
                .Add<CollectBusResource>("en")
                .AddBaseTypes(typeof(AbpValidationResource))
                .AddVirtualJson("/Localization/CollectBus");
        });

        Configure<AbpExceptionLocalizationOptions>(options =>
        {
            options.MapCodeNamespace("CollectBus", typeof(CollectBusResource));
        });
    }

    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.OnRegistered(ProtocolInspectInterceptorRegistrar.RegisterIfNeeded);
    }
}
