mirror of https://github.com/abpframework/abp.git
27 changed files with 295 additions and 95 deletions
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait ContinueOnCapturedContext="false" /> |
||||
|
</Weavers> |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,25 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.1</TargetFramework> |
||||
|
<AssemblyName>Volo.Abp.AspNetCore.Components.WebAssembly</AssemblyName> |
||||
|
<PackageId>Volo.Abp.AspNetCore.Components.WebAssembly</PackageId> |
||||
|
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
||||
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
||||
|
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
||||
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.Client.Common\Volo.Abp.AspNetCore.Mvc.Client.Common.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,13 @@ |
|||||
|
using Volo.Abp.AspNetCore.Mvc.Client; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.WebAssembly |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(AbpAspNetCoreMvcClientCommonModule) |
||||
|
)] |
||||
|
public class AbpAspNetCoreComponentsWebAssemblyModule : AbpModule |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,36 @@ |
|||||
|
using System.Globalization; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; |
||||
|
using Volo.Abp.AspNetCore.Mvc.Client; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Http.Client.DynamicProxying; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.WebAssembly |
||||
|
{ |
||||
|
public class WebAssemblyCachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency |
||||
|
{ |
||||
|
protected IHttpClientProxy<IAbpApplicationConfigurationAppService> Proxy { get; } |
||||
|
protected ICurrentUser CurrentUser { get; } |
||||
|
|
||||
|
public WebAssemblyCachedApplicationConfigurationClient( |
||||
|
IHttpClientProxy<IAbpApplicationConfigurationAppService> proxy, |
||||
|
ICurrentUser currentUser) |
||||
|
{ |
||||
|
Proxy = proxy; |
||||
|
CurrentUser = currentUser; |
||||
|
} |
||||
|
|
||||
|
public async Task<ApplicationConfigurationDto> GetAsync() |
||||
|
{ |
||||
|
//TODO: Cache
|
||||
|
|
||||
|
return await Proxy.Service.GetAsync(); |
||||
|
} |
||||
|
|
||||
|
protected virtual string CreateCacheKey() |
||||
|
{ |
||||
|
return $"ApplicationConfiguration_{CurrentUser.Id?.ToString("N") ?? "Anonymous"}_{CultureInfo.CurrentUICulture.Name}"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,69 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.AspNetCore.Mvc.MultiTenancy; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Http.Client.DynamicProxying; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.WebAssembly |
||||
|
{ |
||||
|
public class WebAssemblyRemoteTenantStore : ITenantStore, ITransientDependency |
||||
|
{ |
||||
|
protected IHttpClientProxy<IAbpTenantAppService> Proxy { get; } |
||||
|
|
||||
|
public WebAssemblyRemoteTenantStore( |
||||
|
IHttpClientProxy<IAbpTenantAppService> proxy) |
||||
|
{ |
||||
|
Proxy = proxy; |
||||
|
} |
||||
|
|
||||
|
public async Task<TenantConfiguration> FindAsync(string name) |
||||
|
{ |
||||
|
//TODO: Cache
|
||||
|
|
||||
|
return CreateTenantConfiguration(await Proxy.Service.FindTenantByNameAsync(name)); |
||||
|
} |
||||
|
|
||||
|
public async Task<TenantConfiguration> FindAsync(Guid id) |
||||
|
{ |
||||
|
//TODO: Cache
|
||||
|
|
||||
|
return CreateTenantConfiguration(await Proxy.Service.FindTenantByIdAsync(id)); |
||||
|
} |
||||
|
|
||||
|
public TenantConfiguration Find(string name) |
||||
|
{ |
||||
|
//TODO: Cache
|
||||
|
|
||||
|
return AsyncHelper.RunSync(async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByNameAsync(name))); |
||||
|
} |
||||
|
|
||||
|
public TenantConfiguration Find(Guid id) |
||||
|
{ |
||||
|
//TODO: Cache
|
||||
|
|
||||
|
return AsyncHelper.RunSync(async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByIdAsync(id))); |
||||
|
} |
||||
|
|
||||
|
protected virtual TenantConfiguration CreateTenantConfiguration(FindTenantResultDto tenantResultDto) |
||||
|
{ |
||||
|
if (!tenantResultDto.Success || tenantResultDto.TenantId == null) |
||||
|
{ |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
return new TenantConfiguration(tenantResultDto.TenantId.Value, tenantResultDto.Name); |
||||
|
} |
||||
|
|
||||
|
protected virtual string CreateCacheKey(string tenantName) |
||||
|
{ |
||||
|
return $"RemoteTenantStore_Name_{tenantName}"; |
||||
|
} |
||||
|
|
||||
|
protected virtual string CreateCacheKey(Guid tenantId) |
||||
|
{ |
||||
|
return $"RemoteTenantStore_Id_{tenantId:N}"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait ContinueOnCapturedContext="false" /> |
||||
|
</Weavers> |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,24 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<AssemblyName>Volo.Abp.AspNetCore.Mvc.Client.Common</AssemblyName> |
||||
|
<PackageId>Volo.Abp.AspNetCore.Mvc.Client.Common</PackageId> |
||||
|
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
||||
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
||||
|
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
||||
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.Contracts\Volo.Abp.AspNetCore.Mvc.Contracts.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Abp.Caching\Volo.Abp.Caching.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Abp.Http.Client\Volo.Abp.Http.Client.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Abp.Localization\Volo.Abp.Localization.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,33 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.Http.Client; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.Client |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(AbpHttpClientModule), |
||||
|
typeof(AbpAspNetCoreMvcContractsModule), |
||||
|
typeof(AbpCachingModule), |
||||
|
typeof(AbpLocalizationModule) |
||||
|
)] |
||||
|
public class AbpAspNetCoreMvcClientCommonModule : AbpModule |
||||
|
{ |
||||
|
public const string RemoteServiceName = "AbpMvcClient"; |
||||
|
|
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
context.Services.AddHttpClientProxies( |
||||
|
typeof(AbpAspNetCoreMvcContractsModule).Assembly, |
||||
|
RemoteServiceName, |
||||
|
asDefaultServices: false |
||||
|
); |
||||
|
|
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.GlobalContributors.Add<RemoteLocalizationContributor>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,33 +1,11 @@ |
|||||
using Microsoft.Extensions.DependencyInjection; |
using Volo.Abp.Modularity; |
||||
using Volo.Abp.Caching; |
|
||||
using Volo.Abp.Http.Client; |
|
||||
using Volo.Abp.Localization; |
|
||||
using Volo.Abp.Modularity; |
|
||||
|
|
||||
namespace Volo.Abp.AspNetCore.Mvc.Client |
namespace Volo.Abp.AspNetCore.Mvc.Client |
||||
{ |
{ |
||||
[DependsOn( |
[DependsOn( |
||||
typeof(AbpHttpClientModule), |
typeof(AbpAspNetCoreMvcClientCommonModule) |
||||
typeof(AbpAspNetCoreMvcContractsModule), |
|
||||
typeof(AbpCachingModule), |
|
||||
typeof(AbpLocalizationModule) |
|
||||
)] |
)] |
||||
public class AbpAspNetCoreMvcClientModule : AbpModule |
public class AbpAspNetCoreMvcClientModule : AbpModule |
||||
{ |
{ |
||||
public const string RemoteServiceName = "AbpMvcClient"; |
|
||||
|
|
||||
public override void ConfigureServices(ServiceConfigurationContext context) |
|
||||
{ |
|
||||
context.Services.AddHttpClientProxies( |
|
||||
typeof(AbpAspNetCoreMvcContractsModule).Assembly, |
|
||||
RemoteServiceName, |
|
||||
asDefaultServices: false |
|
||||
); |
|
||||
|
|
||||
Configure<AbpLocalizationOptions>(options => |
|
||||
{ |
|
||||
options.GlobalContributors.Add<RemoteLocalizationContributor>(); |
|
||||
}); |
|
||||
} |
|
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,55 +0,0 @@ |
|||||
@page "/fetchdata" |
|
||||
@inject HttpClient Http |
|
||||
|
|
||||
<h1>Weather forecast</h1> |
|
||||
|
|
||||
<p>This component demonstrates fetching data from the server.</p> |
|
||||
|
|
||||
@if (forecasts == null) |
|
||||
{ |
|
||||
<p><em>Loading...</em></p> |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
<table class="table"> |
|
||||
<thead> |
|
||||
<tr> |
|
||||
<th>Date</th> |
|
||||
<th>Temp. (C)</th> |
|
||||
<th>Temp. (F)</th> |
|
||||
<th>Summary</th> |
|
||||
</tr> |
|
||||
</thead> |
|
||||
<tbody> |
|
||||
@foreach (var forecast in forecasts) |
|
||||
{ |
|
||||
<tr> |
|
||||
<td>@forecast.Date.ToShortDateString()</td> |
|
||||
<td>@forecast.TemperatureC</td> |
|
||||
<td>@forecast.TemperatureF</td> |
|
||||
<td>@forecast.Summary</td> |
|
||||
</tr> |
|
||||
} |
|
||||
</tbody> |
|
||||
</table> |
|
||||
} |
|
||||
|
|
||||
@code { |
|
||||
private WeatherForecast[] forecasts; |
|
||||
|
|
||||
protected override async Task OnInitializedAsync() |
|
||||
{ |
|
||||
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json"); |
|
||||
} |
|
||||
|
|
||||
public class WeatherForecast |
|
||||
{ |
|
||||
public DateTime Date { get; set; } |
|
||||
|
|
||||
public int TemperatureC { get; set; } |
|
||||
|
|
||||
public string Summary { get; set; } |
|
||||
|
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue