Skip to content

Commit

Permalink
Use static proxying for identity module.
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalkan committed Sep 1, 2021
1 parent ae5febe commit 6f87944
Show file tree
Hide file tree
Showing 13 changed files with 1,245 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ClientProxyApiDescriptionFinder : IClientProxyApiDescriptionFinder,
JsonSerializer = jsonSerializer;
ActionApiDescriptionModels = new Dictionary<string, ActionApiDescriptionModel>();

Initial();
Initialize();
}

public Task<ActionApiDescriptionModel> FindActionAsync(string methodName)
Expand All @@ -39,7 +39,7 @@ public Task<ApplicationApiDescriptionModel> GetApiDescriptionAsync()
return Task.FromResult(ApplicationApiDescriptionModel);
}

private void Initial()
private void Initialize()
{
ApplicationApiDescriptionModel = GetApplicationApiDescriptionModel();
var controllers = ApplicationApiDescriptionModel.Modules.Select(x=>x.Value).SelectMany(x => x.Controllers.Values).ToList();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Modeling;
Expand All @@ -21,12 +20,14 @@ protected virtual async Task RequestAsync(string methodName, params object[] arg

protected virtual async Task<T> RequestAsync<T>(string methodName, params object[] arguments)
{
return await HttpProxyExecuter.MakeRequestAndGetResultAsync<T>(await BuildHttpProxyExecuterContext(methodName, arguments));
return await HttpProxyExecuter.MakeRequestAndGetResultAsync<T>(
await BuildHttpProxyExecuterContext(methodName, arguments)
);
}

protected virtual async Task<HttpProxyExecuterContext> BuildHttpProxyExecuterContext(string methodName, params object[] arguments)
{
var actionKey = GetActionKey(typeof(TService).FullName, methodName, arguments);
var actionKey = GetActionKey(methodName, arguments);
var action = await ClientProxyApiDescriptionFinder.FindActionAsync(actionKey);

return new HttpProxyExecuterContext(action, BuildArguments(action, arguments), typeof(TService));
Expand All @@ -45,9 +46,8 @@ protected virtual async Task<HttpProxyExecuterContext> BuildHttpProxyExecuterCon
return dict;
}

private static string GetActionKey(string serviceTypeFullName, string methodName, params object[] arguments)
private static string GetActionKey(string methodName, params object[] arguments)
{

return $"{typeof(TService).FullName}.{methodName}.{string.Join("-", arguments.Select(x => x.GetType().FullName))}";
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
using System;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Abp.Http.Modeling;
using Volo.Abp.Identity;

// ReSharper disable once CheckNamespace
namespace Volo.Abp.Identity.HttpApi.Client.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IIdentityRoleAppService))]
public partial class IdentityRoleClientProxy : ClientProxyBase<IIdentityRoleAppService>, IIdentityRoleAppService
{
public virtual async Task<ListResultDto<IdentityRoleDto>> GetAllListAsync()
{
return await RequestAsync<ListResultDto<IdentityRoleDto>>(nameof(GetAllListAsync));
}

public virtual async Task<PagedResultDto<IdentityRoleDto>> GetListAsync(GetIdentityRolesInput input)
{
return await RequestAsync<PagedResultDto<IdentityRoleDto>>(nameof(GetListAsync), input);
}

public virtual async Task<IdentityRoleDto> GetAsync(Guid id)
{
return await RequestAsync<IdentityRoleDto>(nameof(GetAsync), id);
}

public virtual async Task<IdentityRoleDto> CreateAsync(IdentityRoleCreateDto input)
{
return await RequestAsync<IdentityRoleDto>(nameof(CreateAsync), input);
}

public virtual async Task<IdentityRoleDto> UpdateAsync(Guid id, IdentityRoleUpdateDto input)
{
return await RequestAsync<IdentityRoleDto>(nameof(UpdateAsync), id, input);
}

public virtual async Task DeleteAsync(Guid id)
{
await RequestAsync(nameof(DeleteAsync), id);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file is part of IdentityRoleClientProxy, you can customize it here
namespace Volo.Abp.Identity.HttpApi.Client.ClientProxies
{
public partial class IdentityRoleClientProxy
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
using System;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Abp.Http.Modeling;
using Volo.Abp.Identity;

namespace Volo.Abp.Identity.HttpApi.Client.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IIdentityUserAppService))]
public partial class IdentityUserClientProxy : ClientProxyBase<IIdentityUserAppService>, IIdentityUserAppService
{
public virtual async Task<IdentityUserDto> GetAsync(Guid id)
{
return await RequestAsync<IdentityUserDto>(nameof(GetAsync), id);
}

public virtual async Task<PagedResultDto<IdentityUserDto>> GetListAsync(GetIdentityUsersInput input)
{
return await RequestAsync<PagedResultDto<IdentityUserDto>>(nameof(GetListAsync), input);
}

public virtual async Task<IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
{
return await RequestAsync<IdentityUserDto>(nameof(CreateAsync), input);
}

public virtual async Task<IdentityUserDto> UpdateAsync(Guid id, IdentityUserUpdateDto input)
{
return await RequestAsync<IdentityUserDto>(nameof(UpdateAsync), id, input);
}

public virtual async Task DeleteAsync(Guid id)
{
await RequestAsync(nameof(DeleteAsync), id);
}

public virtual async Task<ListResultDto<IdentityRoleDto>> GetRolesAsync(Guid id)
{
return await RequestAsync<ListResultDto<IdentityRoleDto>>(nameof(GetRolesAsync), id);
}

public virtual async Task<ListResultDto<IdentityRoleDto>> GetAssignableRolesAsync()
{
return await RequestAsync<ListResultDto<IdentityRoleDto>>(nameof(GetAssignableRolesAsync));
}

public virtual async Task UpdateRolesAsync(Guid id, IdentityUserUpdateRolesDto input)
{
await RequestAsync(nameof(UpdateRolesAsync), id, input);
}

public virtual async Task<IdentityUserDto> FindByUsernameAsync(string userName)
{
return await RequestAsync<IdentityUserDto>(nameof(FindByUsernameAsync), userName);
}

public virtual async Task<IdentityUserDto> FindByEmailAsync(string email)
{
return await RequestAsync<IdentityUserDto>(nameof(FindByEmailAsync), email);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file is part of IdentityUserClientProxy, you can customize it here
namespace Volo.Abp.Identity.HttpApi.Client.ClientProxies
{
public partial class IdentityUserClientProxy
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
using System;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Abp.Http.Modeling;
using Volo.Abp.Identity;
using Volo.Abp.Users;

namespace Volo.Abp.Identity.HttpApi.Client.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IIdentityUserLookupAppService))]
public partial class IdentityUserLookupClientProxy : ClientProxyBase<IIdentityUserLookupAppService>, IIdentityUserLookupAppService
{
public virtual async Task<UserData> FindByIdAsync(Guid id)
{
return await RequestAsync<UserData>(nameof(FindByIdAsync), id);
}

public virtual async Task<UserData> FindByUserNameAsync(string userName)
{
return await RequestAsync<UserData>(nameof(FindByUserNameAsync), userName);
}

public virtual async Task<ListResultDto<UserData>> SearchAsync(UserLookupSearchInputDto input)
{
return await RequestAsync<ListResultDto<UserData>>(nameof(SearchAsync), input);
}

public virtual async Task<long> GetCountAsync(UserLookupCountInputDto input)
{
return await RequestAsync<long>(nameof(GetCountAsync), input);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file is part of IdentityUserLookupClientProxy, you can customize it here
namespace Volo.Abp.Identity.HttpApi.Client.ClientProxies
{
public partial class IdentityUserLookupClientProxy
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
using System;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Abp.Http.Modeling;
using Volo.Abp.Identity;

namespace Volo.Abp.Identity.HttpApi.Client.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IProfileAppService))]
public partial class ProfileClientProxy : ClientProxyBase<IProfileAppService>, IProfileAppService
{
public virtual async Task<ProfileDto> GetAsync()
{
return await RequestAsync<ProfileDto>(nameof(GetAsync));
}

public virtual async Task<ProfileDto> UpdateAsync(UpdateProfileDto input)
{
return await RequestAsync<ProfileDto>(nameof(UpdateAsync), input);
}

public virtual async Task ChangePasswordAsync(ChangePasswordInput input)
{
await RequestAsync(nameof(ChangePasswordAsync), input);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file is part of ProfileClientProxy, you can customize it here
namespace Volo.Abp.Identity.HttpApi.Client.ClientProxies
{
public partial class ProfileClientProxy
{
}
}

0 comments on commit 6f87944

Please sign in to comment.