注意:我正在使用的示例可在 GitHub 存储库https://github.com/mary-perret-1986/primevue-poc上找到
\n我使用 Vue.js 3 + Vite + PrimeVue 创建了一个简单的项目。
\n到目前为止,当我正在开发并且正在为构建提供服务时(即/dist服务器提供构建(即)时,一切都像魅力一样。
但我想看看我是否可以打开/dist/index.html直接从浏览器打开......我的意思是,从技术上讲,这应该是可能的。
以下是配置部分:
\npackage.json
{\n "name": "my-vue-app",\n "version": "0.0.0",\n "scripts": {\n "dev": "vite",\n "build": "vite build",\n "preview": "vite build && vite preview"\n },\n "dependencies": {\n "primeflex": "^2.0.0",\n "primeicons": "^4.1.0",\n "primevue": "^3.2.0-rc.1",\n "vue": "^3.0.5",\n "vue-property-decorator": "^9.1.2",\n "vue-class-component": "^8.0.0-0",\n "vue-router": "^4.0.0-0",\n "vuex": "^4.0.0-0"\n },\n "devDependencies": {\n "@types/node": "^14.14.37",\n "@vitejs/plugin-vue": "^1.2.1",\n "@vue/compiler-sfc": "^3.0.5",\n "sass": "^1.26.5",\n "typescript": "^4.1.3",\n "vite": "^2.1.5",\n "vue-tsc": "^0.0.15"\n …Run Code Online (Sandbox Code Playgroud) 我正在阅读这篇关于 DateTime 相关格式支持的 MSDocs 文章 https://learn.microsoft.com/en-us/dotnet/standard/datetime/system-text-json-support#support-for-the-iso-8601- 12019-格式
我试图弄清楚默认配置没有按预期工作,或者我一定错过了一些东西。
我是说:
DateTimeOffset.Parse("2021-03-17T12:03:14+0000");
Run Code Online (Sandbox Code Playgroud)
效果很好。
但
JsonSerializer.Deserialize<TestType>(@"{ ""CreationDate"": ""2021-03-17T12:03:14+0000"" }");
Run Code Online (Sandbox Code Playgroud)
没有。
例子:
using System;
using System.Text.Json;
using System.Threading.Tasks;
namespace CSharpPlayground
{
public record TestType(DateTimeOffset CreationDate);
public static class Program
{
public static void Main()
{
var dto = DateTimeOffset.Parse("2021-03-17T12:03:14+0000");
Console.WriteLine(dto);
var testType = JsonSerializer.Deserialize<TestType>(@"{ ""CreationDate"": ""2021-03-17T12:03:14+0000"" }");
Console.WriteLine(testType.CreationDate);
}
}
}
Run Code Online (Sandbox Code Playgroud)
抛出以下异常:
System.Text.Json.JsonException: The JSON value could not be converted to CSharpPlayground.TestType. Path: $.CreationDate | LineNumber: 0 | BytePositionInLine: 44.
---> System.FormatException: The JSON …Run Code Online (Sandbox Code Playgroud) 前几天,在我的一个实用程序中,ReSharper向我暗示了下面的代码段,声明定义委托的lambda ThreadStart可以转换为本地函数:
public void Start(ThreadPriority threadPriority = ThreadPriority.Lowest)
{
if (!Enabled)
{
_threadCancellationRequested = false;
ThreadStart threadStart = () => NotificationTimer (ref _interval, ref _ignoreDurationThreshold, ref _threadCancellationRequested);
Thread = new Thread(threadStart) {Priority = ThreadPriority.Lowest};
Thread.Start();
}
}
Run Code Online (Sandbox Code Playgroud)
因此转变为:
public void Start(ThreadPriority threadPriority = ThreadPriority.Lowest)
{
if (!Enabled)
{
_threadCancellationRequested = false;
void ThreadStart() => NotificationTimer(ref _interval, ref _ignoreDurationThreshold, ref _threadCancellationRequested);
Thread = new Thread(ThreadStart) {Priority = ThreadPriority.Lowest};
Thread.Start();
}
}
Run Code Online (Sandbox Code Playgroud)
后者相对于前者有什么好处,它只是关于性能吗?
我已经检查了下面的资源,但在我的例子中,好处并不那么明显:
我们在生产中使用 Hangfire,结果发现我们确实达到了数据库连接最大限制。
我们有大约 45 个连接用于hangfire,这对于维护一些长时间运行的任务来说似乎有点太多了。
我想知道是否可以采取任何措施来更改连接数,但是,我在配置中找不到提供此类配置的任何内容。
为什么下面的代码导致:
public static class Program
{
public static void Main(params string[] args)
{
var sourceFileName = @"C:\Users\ehoua\Desktop\Stuff\800MFile.exe";
var destinationFileName = sourceFileName + ".bak";
FileCopyAsync(sourceFileName, destinationFileName);
// The line below is actually faster and a lot less CPU-consuming
// File.Copy(sourceFileName, destinationFileName, true);
Console.ReadKey();
}
public static async void FileCopyAsync(string sourceFileName, string destinationFileName, int bufferSize = 0x1000, CancellationToken cancellationToken = default(CancellationToken))
{
using (var sourceFile = File.OpenRead(sourceFileName))
{
using (var destinationFile = File.OpenWrite(destinationFileName))
{
Console.WriteLine($"Copying {sourceFileName} to {destinationFileName}...");
await sourceFile.CopyToAsync(destinationFile, bufferSize, cancellationToken); …Run Code Online (Sandbox Code Playgroud) 我有一个 HTML 5 视频标签指向我的 ASP.NET WebAPI,它需要承载身份验证,我对 API 的大多数请求如下所示:
GET http://localhost:29080/api/v1/users/me HTTP/1.1
Host: localhost:29080
Connection: keep-alive
Accept: application/json, text/plain, */*
Origin: http://localhost:4200
Authorization: Bearer c66b36fe-fcc1-49da-9b42-dac783768a06
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
Referer: http://localhost:4200/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,fr;q=0.8
Run Code Online (Sandbox Code Playgroud)
由于应用程序托管在不同的端口(最终是不同的地址)上,因此它受到 CORS 的约束。我已经将我的 WebAPI 设置为兼容的:
config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
Run Code Online (Sandbox Code Playgroud)
遗憾的是,我的 HTML 5 视频标签似乎无法使用该设置。
<video
crossorigin="use-credentials"
src="http://localhost:29080/api/v1/entities/470/presentation-video">
Run Code Online (Sandbox Code Playgroud)
我最终得到:
Failed to load http://localhost:29080/api/v1/entities/470/presentation-video:
The value of the 'Access-Control-Allow-Origin' header in the response must
not be the wildcard …Run Code Online (Sandbox Code Playgroud) 为什么在cmd中运行以下命令(当前目录是我的visual studio项目的根目录)时,一切都很好:
npm install
webpack --config webpack.config.vendor.js
webpack
Run Code Online (Sandbox Code Playgroud)
但是当要求在我的ASP.NET Core 2.0中使用Visual Studio 2017运行它时,它会挂在第一行(虽然它不需要任何用户输入).当我说它挂起时,它会挂起大约3-5分钟(之后)使用call执行最后一行,就像字面意思一样.
我设法通过对每个调用使用它们来进一步调用(MS文档建议调用.bat脚本):
call npm install
call webpack --config webpack.config.vendor.js
call webpack
Run Code Online (Sandbox Code Playgroud)
由于某些原因,它可以工作,只挂在最后一行.
当尝试一些简单的事情就像echo there一切都很好,我真的不明白上面的行是什么问题.
[编辑]已经检查过npm挂起任何命令
但我的问题似乎有所不同,因为它可以运行cmd和PowerShell(但只要它在ISE PowerShell选项卡中运行就会挂起......)
前几天我正在重构一些东西,我遇到了这样的事情:
public async Task<Result> Handle(CancelInitiatedCashoutCommand command, CancellationToken cancellationToken)
{
using (_logger.BeginScope("{@CancelCashoutCommand}", command))
{
return await GetCashoutAsync(command.CashoutId)
.Bind(IsStatePending)
.Tap(SetCancelledStateAsync)
.Tap(_ => _logger.LogInformation("Cashout cancellation succeeded."));
}
}
Run Code Online (Sandbox Code Playgroud)
ReSharper 建议将其重构为:
public async Task<Result> Handle(CancelInitiatedCashoutCommand command, CancellationToken cancellationToken)
{
using var scope = _logger.BeginScope("{@CancelCashoutCommand}", command);
return await GetCashoutAsync(command.CashoutId)
.Bind(IsStatePending)
.Tap(SetCancelledStateAsync)
.Tap(_ => _logger.LogInformation("Cashout cancellation succeeded."));
}
Run Code Online (Sandbox Code Playgroud)
我有点怀疑,实际上我不确定Dispose第二个版本何时会发生隐式调用。
我怎么知道?
只是想知道是否对在PowerShell中被视为枚举和类成员(方法和字段/属性)文档的注释有任何支持?
我正在查看Dictionary<TKey, TValue>.NET Core 中的代码,并且注意到一种编码模式也用于某些内置数据结构(例如Queue<T>或Stack<T>和)中List<T>。
例如:https : //github.com/dotnet/coreclr/blob/master/src/System.Private.CoreLib/shared/System/Collections/Generic/Dictionary.cs#L482
我们有:
Entry[] entries = _entries;
IEqualityComparer<TKey> comparer = _comparer;
Run Code Online (Sandbox Code Playgroud)
我不太确定为什么我们要保留比较器的引用和条目的变量,对我来说,它仍然引用相同的字段。
如果使用相同的方法主体,这并不像在某个时候重新分配了该字段。
如果没有重新分配引用,并且编译器进行了一些优化来避免this.field遍历,那么复制引用又有什么用呢?
c# ×6
.net ×4
.net-core ×3
angular ×1
asynchronous ×1
cors ×1
dispose ×1
file-copying ×1
hangfire ×1
io ×1
javascript ×1
json ×1
lambda ×1
methods ×1
npm ×1
postgresql ×1
powershell ×1
primevue ×1
typescript ×1
vite ×1
vuejs3 ×1
webpack ×1