Make .netcoreapp 3.0 build happy

This commit is contained in:
nicolas.dorier 2019-10-03 18:00:07 +09:00
parent aaa05eb5ec
commit e75edac3c1
No known key found for this signature in database
GPG Key ID: 6618763EF09186FE
10 changed files with 26 additions and 26 deletions

View File

@ -72,6 +72,7 @@
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp2.1'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.0.0"></PackageReference>
</ItemGroup>
<ItemGroup>

View File

@ -393,7 +393,7 @@ namespace BTCPayServer.Controllers
!transactionOutput.SubtractFeesFromOutput)
vm.AddModelError(model => model.Outputs[i].SubtractFeesFromOutput,
"You are sending your entire balance to the same destination, you should subtract the fees",
ModelState);
this);
}
}
@ -402,7 +402,7 @@ namespace BTCPayServer.Controllers
foreach (var subtractFeesOutput in subtractFeesOutputsCount)
{
vm.AddModelError(model => model.Outputs[subtractFeesOutput].SubtractFeesFromOutput,
"You can only subtract fees from one output", ModelState);
"You can only subtract fees from one output", this);
}
}else if (vm.CurrentBalance == transactionAmountSum && !substractFees)
{
@ -415,7 +415,7 @@ namespace BTCPayServer.Controllers
for (var i = 0; i < vm.Outputs.Count; i++)
{
vm.AddModelError(model => model.Outputs[i].Amount,
"You are sending more than what you own", ModelState);
"You are sending more than what you own", this);
}
}

View File

@ -20,7 +20,7 @@ namespace BTCPayServer
!decimal.TryParse(match.Groups[1].Value, out var v))
return false;
var currency = match.Groups.Last().Value.ToUpperInvariant();
var currency = match.Groups[match.Groups.Count - 1].Value.ToUpperInvariant();
var currencyData = _CurrencyTable.GetCurrencyData(currency, false);
if (currencyData == null)
return false;

View File

@ -1,29 +1,29 @@
using System;
using System.Linq.Expressions;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc;
#if NETCOREAPP21
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
#else
using Microsoft.AspNetCore.Mvc.ViewFeatures;
#endif
namespace BTCPayServer
{
public static class ModelStateExtensions
{
public static void AddModelError<TModel, TProperty>(
this ModelStateDictionary modelState,
Expression<Func<TModel, TProperty>> ex,
string message
)
{
var key = ExpressionHelper.GetExpressionText(ex);
modelState.AddModelError(key, message);
}
public static void AddModelError<TModel, TProperty>(this TModel source,
Expression<Func<TModel, TProperty>> ex,
string message,
ModelStateDictionary modelState)
Controller controller)
{
#if NETCOREAPP21
var key = ExpressionHelper.GetExpressionText(ex);
modelState.AddModelError(key, message);
#else
var provider = (ModelExpressionProvider)controller.HttpContext.RequestServices.GetService(typeof(ModelExpressionProvider));
var key = provider.GetExpressionText(ex);
#endif
controller.ModelState.AddModelError(key, message);
}
}
}

View File

@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
namespace BTCPayServer.Filters
{

View File

@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Hosting;
#if NETCOREAPP21
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#else
using Microsoft.Extensions.Hosting;
#endif
using Microsoft.AspNetCore.Builder;
using System;

View File

@ -3,7 +3,6 @@ using NBitcoin;
using System.Reflection;
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Internal;
using NBXplorer.DerivationStrategy;
namespace BTCPayServer.ModelBinders

View File

@ -10,6 +10,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Hosting;
#if NETCOREAPP21
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#else
using Microsoft.Extensions.Hosting;
#endif
namespace BTCPayServer.Services

View File

@ -1,5 +1,3 @@
@using Microsoft.EntityFrameworkCore.Internal
@using Microsoft.EntityFrameworkCore.Storage
@model BTCPayServer.Models.AppViewModels.ContributeToCrowdfund
<form method="post">
@ -8,7 +6,7 @@
<div class="card mb-4 perk expanded" id="@item.Id">
@if (Model.ViewCrowdfundViewModel.DisplayPerksRanking && Model.ViewCrowdfundViewModel.PerkCount.ContainsKey(item.Id))
{
<span class="btn btn-sm rounded-circle px-0 btn-primary perk-badge">#@(Model.ViewCrowdfundViewModel.Perks.IndexOf(item)+1)</span>
<span class="btn btn-sm rounded-circle px-0 btn-primary perk-badge">#@(Array.IndexOf(Model.ViewCrowdfundViewModel.Perks, item) + 1)</span>
}
@if (!string.IsNullOrEmpty(item.Image))
{
@ -31,12 +29,12 @@
@item.Price.Value
if (item.Custom)
{
Safe.Raw("or more");
@Safe.Raw("or more");
}
}
else if (item.Custom)
{
Safe.Raw("Any amount");
@Safe.Raw("Any amount");
}
</span>

View File

@ -16,12 +16,12 @@
<li>
@if (Model.LogFileOffset > 0)
{
<a asp-action="LogsView" asp-route-offset="@(Model.LogFileOffset - 5)"><<</a>
<a asp-action="LogsView" asp-route-offset="@(Model.LogFileOffset - 5)">&lt;&lt;</a>
}
Showing @Model.LogFileOffset - (@(Model.LogFileOffset+Model.LogFiles.Count)) of @Model.LogFileCount
@if ((Model.LogFileOffset+ Model.LogFiles.Count) < Model.LogFileCount)
{
<a asp-action="LogsView" asp-route-offset="@(Model.LogFileOffset + Model.LogFiles.Count)">>></a>
<a asp-action="LogsView" asp-route-offset="@(Model.LogFileOffset + Model.LogFiles.Count)">&gt;&gt;</a>
}
</li>
</ul>