fix: update ConfigMapping to configure with MappingOptions
This commit is contained in:
parent
6a04f36388
commit
9332a9161d
@ -50,7 +50,7 @@ try
|
|||||||
builder.Services.AddWorkFlowServices(opt =>
|
builder.Services.AddWorkFlowServices(opt =>
|
||||||
{
|
{
|
||||||
opt.MediatRLicense = mediatRLicense;
|
opt.MediatRLicense = mediatRLicense;
|
||||||
opt.ConfigMapping(config);
|
opt.ConfigMapping(config.GetSection("MappingOptions"));
|
||||||
}).AddWorkFlowRepositories();
|
}).AddWorkFlowRepositories();
|
||||||
|
|
||||||
builder.Services.AddUserManager<WFDBContext>();
|
builder.Services.AddUserManager<WFDBContext>();
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"MappingOptions": {
|
"MappingOptions": {
|
||||||
"TfFileUri": {
|
"TfFileUri": {
|
||||||
"Scheme": "https",
|
"Scheme": "https",
|
||||||
"Host": " dd-gan.digitaldata.works",
|
"Host": "dd-gan.digitaldata.works",
|
||||||
"Port": 8443,
|
"Port": 8443,
|
||||||
"Path": "api/file"
|
"Path": "api/file"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -21,8 +21,8 @@ public static class DependencyInjection
|
|||||||
if(!sOptions.IsMappingConfigured)
|
if(!sOptions.IsMappingConfigured)
|
||||||
services.Configure<MappingOptions>(_ => { });
|
services.Configure<MappingOptions>(_ => { });
|
||||||
|
|
||||||
services.AddTransient<TfFileUriBuilderResolver>();
|
services.AddTransient<TfFileUriResolver>();
|
||||||
services.AddTransient<TfFileIconUriBuilderResolver>();
|
services.AddTransient<TfFileIconUriResolver>();
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
public class TfFileDto
|
public class TfFileDto
|
||||||
{
|
{
|
||||||
public UriBuilder? Url { get; set; }
|
public string? Url { get; set; }
|
||||||
|
|
||||||
public string? Headline { get; set; }
|
public string? Headline { get; set; }
|
||||||
|
|
||||||
@ -10,5 +10,5 @@ public class TfFileDto
|
|||||||
|
|
||||||
public string? Comment { get; set; }
|
public string? Comment { get; set; }
|
||||||
|
|
||||||
public UriBuilder? IconUrl { get; set; }
|
public string? IconUrl { get; set; }
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ public class MappingProfile : AutoMapper.Profile
|
|||||||
.ForMember(dest => dest.Others, opt => opt.MapFrom(src => new string?[] { src.State2, src.State3, src.State4 }));
|
.ForMember(dest => dest.Others, opt => opt.MapFrom(src => new string?[] { src.State2, src.State3, src.State4 }));
|
||||||
|
|
||||||
CreateMap<TfFile, TfFileDto>()
|
CreateMap<TfFile, TfFileDto>()
|
||||||
.ForMember(dest => dest.Url, opt => opt.MapFrom<TfFileUriBuilderResolver>())
|
.ForMember(dest => dest.Url, opt => opt.MapFrom<TfFileUriResolver>())
|
||||||
.ForMember(dest => dest.IconUrl, opt => opt.MapFrom<TfFileIconUriBuilderResolver>());
|
.ForMember(dest => dest.IconUrl, opt => opt.MapFrom<TfFileIconUriResolver>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6,19 +6,19 @@ using WorkFlow.Domain.Entities;
|
|||||||
|
|
||||||
namespace WorkFlow.Application.Mapping;
|
namespace WorkFlow.Application.Mapping;
|
||||||
|
|
||||||
public class TfFileIconUriBuilderResolver : IValueResolver<TfFile, TfFileDto, UriBuilder?>
|
public class TfFileIconUriResolver : IValueResolver<TfFile, TfFileDto, string?>
|
||||||
{
|
{
|
||||||
private readonly Func<UriBuilder> _uriBuilderFactory;
|
private readonly Func<UriBuilder> _uriBuilderFactory;
|
||||||
|
|
||||||
public TfFileIconUriBuilderResolver(IOptions<MappingOptions> options) => _uriBuilderFactory = () => options.Value.TfFileIconUri.ToBuilder;
|
public TfFileIconUriResolver(IOptions<MappingOptions> options) => _uriBuilderFactory = () => options.Value.TfFileIconUri.ToBuilder;
|
||||||
|
|
||||||
public UriBuilder? Resolve(TfFile source, TfFileDto destination, UriBuilder? destMember, ResolutionContext context)
|
public string? Resolve(TfFile source, TfFileDto destination, string? destMember, ResolutionContext context)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(source.Icon))
|
if(string.IsNullOrEmpty(source.Icon))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var builder = _uriBuilderFactory();
|
var builder = _uriBuilderFactory();
|
||||||
builder.AppendPath(source.Icon);
|
builder.AppendPath(source.Icon);
|
||||||
return builder;
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5,19 +5,19 @@ using WorkFlow.Domain.Entities;
|
|||||||
|
|
||||||
namespace WorkFlow.Application.Mapping;
|
namespace WorkFlow.Application.Mapping;
|
||||||
|
|
||||||
public class TfFileUriBuilderResolver : IValueResolver<TfFile, TfFileDto, UriBuilder?>
|
public class TfFileUriResolver : IValueResolver<TfFile, TfFileDto, string?>
|
||||||
{
|
{
|
||||||
private readonly Func<UriBuilder> _uriBuilderFactory;
|
private readonly Func<UriBuilder> _uriBuilderFactory;
|
||||||
|
|
||||||
public TfFileUriBuilderResolver(IOptions<MappingOptions> options) => _uriBuilderFactory = () => options.Value.TfFileUri.ToBuilder;
|
public TfFileUriResolver(IOptions<MappingOptions> options) => _uriBuilderFactory = () => options.Value.TfFileUri.ToBuilder;
|
||||||
|
|
||||||
public UriBuilder? Resolve(TfFile source, TfFileDto destination, UriBuilder? destMember, ResolutionContext context)
|
public string? Resolve(TfFile source, TfFileDto destination, string? destMember, ResolutionContext context)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(source.Path))
|
if (string.IsNullOrEmpty(source.Path))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var builder = _uriBuilderFactory();
|
var builder = _uriBuilderFactory();
|
||||||
builder.AppendPath(source.Path);
|
builder.AppendPath(source.Path);
|
||||||
return builder;
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user