Browse Source

Add static proxy for `Volo.Abp.AspNetCore.Mvc.Client.Common`.

Resolve #10518
pull/10519/head
maliming 5 years ago
parent
commit
e79b109da5
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 10
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCachedApplicationConfigurationClient.cs
  2. 23
      framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpApplicationConfigurationClientProxy.Generated.cs
  3. 8
      framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpApplicationConfigurationClientProxy.cs
  4. 34
      framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpTenantClientProxy.Generated.cs
  5. 8
      framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpTenantClientProxy.cs
  6. 169
      framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/abp-generate-proxy.json
  7. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo.Abp.AspNetCore.Mvc.Client.Common.csproj
  8. 15
      framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientCommonModule.cs
  9. 11
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs
  10. 16
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcRemoteTenantStore.cs

10
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCachedApplicationConfigurationClient.cs

@ -1,8 +1,8 @@
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations;
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ClientProxies;
using Volo.Abp.AspNetCore.Mvc.Client;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.DynamicProxying;
using Volo.Abp.MultiTenancy;
namespace Volo.Abp.AspNetCore.Components.WebAssembly
@ -14,25 +14,25 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly
)]
public class WebAssemblyCachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency
{
protected IHttpClientProxy<IAbpApplicationConfigurationAppService> Proxy { get; }
protected AbpApplicationConfigurationClientProxy ApplicationConfigurationAppService { get; }
protected ApplicationConfigurationCache Cache { get; }
protected ICurrentTenantAccessor CurrentTenantAccessor { get; }
public WebAssemblyCachedApplicationConfigurationClient(
IHttpClientProxy<IAbpApplicationConfigurationAppService> proxy,
AbpApplicationConfigurationClientProxy applicationConfigurationAppService,
ApplicationConfigurationCache cache,
ICurrentTenantAccessor currentTenantAccessor)
{
Proxy = proxy;
ApplicationConfigurationAppService = applicationConfigurationAppService;
Cache = cache;
CurrentTenantAccessor = currentTenantAccessor;
}
public virtual async Task InitializeAsync()
{
var configurationDto = await Proxy.Service.GetAsync();
var configurationDto = await ApplicationConfigurationAppService.GetAsync();
Cache.Set(configurationDto);

23
framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpApplicationConfigurationClientProxy.Generated.cs

@ -0,0 +1,23 @@
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Modeling;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations;
// ReSharper disable once CheckNamespace
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IAbpApplicationConfigurationAppService), typeof(AbpApplicationConfigurationClientProxy))]
public partial class AbpApplicationConfigurationClientProxy : ClientProxyBase<IAbpApplicationConfigurationAppService>, IAbpApplicationConfigurationAppService
{
public virtual async Task<ApplicationConfigurationDto> GetAsync()
{
return await RequestAsync<ApplicationConfigurationDto>(nameof(GetAsync));
}
}
}

8
framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpApplicationConfigurationClientProxy.cs

@ -0,0 +1,8 @@
// This file is part of AbpApplicationConfigurationClientProxy, you can customize it here
// ReSharper disable once CheckNamespace
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ClientProxies
{
public partial class AbpApplicationConfigurationClientProxy
{
}
}

34
framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpTenantClientProxy.Generated.cs

@ -0,0 +1,34 @@
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Modeling;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Abp.AspNetCore.Mvc.MultiTenancy;
// ReSharper disable once CheckNamespace
namespace Pages.Abp.MultiTenancy.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IAbpTenantAppService), typeof(AbpTenantClientProxy))]
public partial class AbpTenantClientProxy : ClientProxyBase<IAbpTenantAppService>, IAbpTenantAppService
{
public virtual async Task<FindTenantResultDto> FindTenantByNameAsync(string name)
{
return await RequestAsync<FindTenantResultDto>(nameof(FindTenantByNameAsync), new ClientProxyRequestTypeValue
{
{ typeof(string), name }
});
}
public virtual async Task<FindTenantResultDto> FindTenantByIdAsync(Guid id)
{
return await RequestAsync<FindTenantResultDto>(nameof(FindTenantByIdAsync), new ClientProxyRequestTypeValue
{
{ typeof(Guid), id }
});
}
}
}

8
framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpTenantClientProxy.cs

@ -0,0 +1,8 @@
// This file is part of AbpTenantClientProxy, you can customize it here
// ReSharper disable once CheckNamespace
namespace Pages.Abp.MultiTenancy.ClientProxies
{
public partial class AbpTenantClientProxy
{
}
}

169
framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/abp-generate-proxy.json

@ -0,0 +1,169 @@
{
"modules": {
"abp": {
"rootPath": "abp",
"remoteServiceName": "abp",
"controllers": {
"Pages.Abp.MultiTenancy.AbpTenantController": {
"controllerName": "AbpTenant",
"controllerGroupName": "AbpTenant",
"type": "Pages.Abp.MultiTenancy.AbpTenantController",
"interfaces": [
{
"type": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.IAbpTenantAppService"
}
],
"actions": {
"FindTenantByNameAsyncByName": {
"uniqueName": "FindTenantByNameAsyncByName",
"name": "FindTenantByNameAsync",
"httpMethod": "GET",
"url": "api/abp/multi-tenancy/tenants/by-name/{name}",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "name",
"typeAsString": "System.String, System.Private.CoreLib",
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "name",
"name": "name",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": [],
"bindingSourceId": "Path",
"descriptorName": ""
}
],
"returnValue": {
"type": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.FindTenantResultDto",
"typeSimple": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.FindTenantResultDto"
},
"allowAnonymous": null,
"implementFrom": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.IAbpTenantAppService"
},
"FindTenantByIdAsyncById": {
"uniqueName": "FindTenantByIdAsyncById",
"name": "FindTenantByIdAsync",
"httpMethod": "GET",
"url": "api/abp/multi-tenancy/tenants/by-id/{id}",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "id",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "id",
"name": "id",
"jsonName": null,
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": [],
"bindingSourceId": "Path",
"descriptorName": ""
}
],
"returnValue": {
"type": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.FindTenantResultDto",
"typeSimple": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.FindTenantResultDto"
},
"allowAnonymous": null,
"implementFrom": "Volo.Abp.AspNetCore.Mvc.MultiTenancy.IAbpTenantAppService"
}
}
},
"Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController": {
"controllerName": "AbpApplicationConfiguration",
"controllerGroupName": "AbpApplicationConfiguration",
"type": "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController",
"interfaces": [
{
"type": "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.IAbpApplicationConfigurationAppService"
}
],
"actions": {
"GetAsync": {
"uniqueName": "GetAsync",
"name": "GetAsync",
"httpMethod": "GET",
"url": "api/abp/application-configuration",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto",
"typeSimple": "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto"
},
"allowAnonymous": null,
"implementFrom": "Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.IAbpApplicationConfigurationAppService"
}
}
},
"Volo.Abp.AspNetCore.Mvc.ApiExploring.AbpApiDefinitionController": {
"controllerName": "AbpApiDefinition",
"controllerGroupName": "AbpApiDefinition",
"type": "Volo.Abp.AspNetCore.Mvc.ApiExploring.AbpApiDefinitionController",
"interfaces": [],
"actions": {
"GetByModel": {
"uniqueName": "GetByModel",
"name": "Get",
"httpMethod": "GET",
"url": "api/abp/api-definition",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "model",
"typeAsString": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModelRequestDto, Volo.Abp.Http",
"type": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModelRequestDto",
"typeSimple": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModelRequestDto",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "model",
"name": "IncludeTypes",
"jsonName": null,
"type": "System.Boolean",
"typeSimple": "boolean",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "model"
}
],
"returnValue": {
"type": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModel",
"typeSimple": "Volo.Abp.Http.Modeling.ApplicationApiDescriptionModel"
},
"allowAnonymous": null,
"implementFrom": "Volo.Abp.AspNetCore.Mvc.ApiExploring.AbpApiDefinitionController"
}
}
}
}
}
},
"types": {}
}

4
framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo.Abp.AspNetCore.Mvc.Client.Common.csproj

@ -23,4 +23,8 @@
<ProjectReference Include="..\Volo.Abp.Localization\Volo.Abp.Localization.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="**\*generate-proxy.json" />
<Content Remove="**\*generate-proxy.json" />
</ItemGroup>
</Project>

15
framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientCommonModule.cs

@ -5,6 +5,7 @@ using Volo.Abp.Features;
using Volo.Abp.Http.Client;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.AspNetCore.Mvc.Client
{
@ -14,7 +15,8 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
typeof(AbpCachingModule),
typeof(AbpLocalizationModule),
typeof(AbpAuthorizationModule),
typeof(AbpFeaturesModule)
typeof(AbpFeaturesModule),
typeof(AbpVirtualFileSystemModule)
)]
public class AbpAspNetCoreMvcClientCommonModule : AbpModule
{
@ -22,11 +24,12 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddHttpClientProxies(
typeof(AbpAspNetCoreMvcContractsModule).Assembly,
RemoteServiceName,
asDefaultServices: false
);
context.Services.AddStaticHttpClientProxies(typeof(AbpAspNetCoreMvcContractsModule).Assembly, RemoteServiceName);
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpAspNetCoreMvcClientCommonModule>();
});
Configure<AbpLocalizationOptions>(options =>
{

11
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs

@ -1,12 +1,11 @@
using System;
using System.Globalization;
using Microsoft.AspNetCore.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Distributed;
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations;
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ClientProxies;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.DynamicProxying;
using Volo.Abp.Threading;
using Volo.Abp.Users;
@ -20,17 +19,17 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
public class MvcCachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency
{
protected IHttpContextAccessor HttpContextAccessor { get; }
protected IHttpClientProxy<IAbpApplicationConfigurationAppService> Proxy { get; }
protected AbpApplicationConfigurationClientProxy ApplicationConfigurationAppService { get; }
protected ICurrentUser CurrentUser { get; }
protected IDistributedCache<ApplicationConfigurationDto> Cache { get; }
public MvcCachedApplicationConfigurationClient(
IDistributedCache<ApplicationConfigurationDto> cache,
IHttpClientProxy<IAbpApplicationConfigurationAppService> proxy,
AbpApplicationConfigurationClientProxy applicationConfigurationAppService,
ICurrentUser currentUser,
IHttpContextAccessor httpContextAccessor)
{
Proxy = proxy;
ApplicationConfigurationAppService = applicationConfigurationAppService;
CurrentUser = currentUser;
HttpContextAccessor = httpContextAccessor;
Cache = cache;
@ -53,7 +52,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
configuration = await Cache.GetOrAddAsync(
cacheKey,
async () => await Proxy.Service.GetAsync(),
async () => await ApplicationConfigurationAppService.GetAsync(),
() => new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300) //TODO: Should be configurable.

16
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcRemoteTenantStore.cs

@ -2,10 +2,10 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Caching.Distributed;
using Pages.Abp.MultiTenancy.ClientProxies;
using Volo.Abp.AspNetCore.Mvc.MultiTenancy;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.DynamicProxying;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Threading;
@ -13,16 +13,16 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
{
public class MvcRemoteTenantStore : ITenantStore, ITransientDependency
{
protected IHttpClientProxy<IAbpTenantAppService> Proxy { get; }
protected AbpTenantClientProxy TenantAppService { get; }
protected IHttpContextAccessor HttpContextAccessor { get; }
protected IDistributedCache<TenantConfiguration> Cache { get; }
public MvcRemoteTenantStore(
IHttpClientProxy<IAbpTenantAppService> proxy,
AbpTenantClientProxy tenantAppService,
IHttpContextAccessor httpContextAccessor,
IDistributedCache<TenantConfiguration> cache)
{
Proxy = proxy;
TenantAppService = tenantAppService;
HttpContextAccessor = httpContextAccessor;
Cache = cache;
}
@ -39,7 +39,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
tenantConfiguration = await Cache.GetOrAddAsync(
cacheKey,
async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByNameAsync(name)),
async () => CreateTenantConfiguration(await TenantAppService.FindTenantByNameAsync(name)),
() => new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow =
@ -67,7 +67,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
tenantConfiguration = await Cache.GetOrAddAsync(
cacheKey,
async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByIdAsync(id)),
async () => CreateTenantConfiguration(await TenantAppService.FindTenantByIdAsync(id)),
() => new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow =
@ -95,7 +95,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
tenantConfiguration = Cache.GetOrAdd(
cacheKey,
() => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByNameAsync(name))),
() => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await TenantAppService.FindTenantByNameAsync(name))),
() => new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow =
@ -123,7 +123,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
tenantConfiguration = Cache.GetOrAdd(
cacheKey,
() => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByIdAsync(id))),
() => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await TenantAppService.FindTenantByIdAsync(id))),
() => new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow =

Loading…
Cancel
Save