小编use*_*444的帖子

如何检查控制器是否安装了 Flutter GetX?

我有以下代码:

Get.put(DbController(HabitDao(AppDb())));
Run Code Online (Sandbox Code Playgroud)

当我热重新加载我的应用程序时,出现以下错误:

"WARNING (moor): It looks like you've created the database class AppDb multiple times. When these two databases use the same QueryExecutor, race conditions will occur and might corrupt the database."
Run Code Online (Sandbox Code Playgroud)

DbController我需要检查在创建新实例之前是否放置了 a AppDb。我在使用 Provider 包时从未遇到过这个问题。

解决这个问题的最佳实践是什么?

dart flutter flutter-getx

10
推荐指数
1
解决办法
9210
查看次数

Android 约束布局未按预期工作

我有一个根标签为

androidx.constraintlayout.widget.ConstraintLayout
Run Code Online (Sandbox Code Playgroud)

我在此活动中包含 3 个布局文件并垂直列出它们。以下对中间的约束不起作用

    app:layout_constraintTop_toBottomOf="@+id/lay1"
    app:layout_constraintBottom_toTopOf="@+id/lay3"
Run Code Online (Sandbox Code Playgroud)

我不明白为什么中间一个占据整个屏幕而不是从顶部的底部开始并在底部的顶部结束。你能帮我么?

活动:

<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include
        android:id="@+id/lay1"
        layout="@layout/empty_linear_layout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <include
        android:id="@+id/lay2"
        layout="@layout/empty_linear_layout"
        app:layout_constraintBottom_toTopOf="@+id/lay3"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/lay1" />

    <include
        android:id="@+id/lay3"
        layout="@layout/empty_linear_layout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

empty_linear_layout.xml :

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:id="@+id/button"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:text="button" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

xml android android-layout android-constraintlayout

7
推荐指数
2
解决办法
2554
查看次数

如何解决 Blazor 上的“TypeError: Failed to fetch”错误?

我正在尝试从我的 Blazor 应用程序向我的 ASP.NET Core API 发送 HTTP 请求。我到处都有断点。应用程序在 API 控制器上的操作方法返回后立即给出异常。我对 .NET 总体上很熟悉,但是,我无法破译错误消息。

Blazor http 调用:

var response = await _httpClient.GetStreamAsync($"Customer/GetAllCustomers");
Run Code Online (Sandbox Code Playgroud)

ASP.NET Core API 控制器操作:

[HttpGet]
[Route("GetAllCustomers")]
public async Task<IEnumerable<Customer>> GetAllCustomersAsync()
{
    return await _service.GetAllCustomersAsync();
}
Run Code Online (Sandbox Code Playgroud)

错误堆栈:

Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: TypeError: Failed to fetch
WebAssembly.JSException: TypeError: Failed to fetch
  at System.Net.Http.WebAssemblyHttpHandler.doFetch (System.Threading.Tasks.TaskCompletionSource`1[TResult] tcs, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0x301ab40 + 0x00a30> in <filename unknown>:0 
  at System.Net.Http.WebAssemblyHttpHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0x2ff3590 + 0x00174> in <filename unknown>:0 
  at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync (System.Net.Http.HttpRequestMessage …
Run Code Online (Sandbox Code Playgroud)

asp.net-web-api asp.net-core blazor blazor-client-side

7
推荐指数
2
解决办法
4804
查看次数

尝试搜索 NuGet 包时无法创建 SSL/TLS 安全通道

当我在 Visual Studio 中按下 NuGet 包上的“浏览”选项卡时,它显示“发生错误”并显示错误消息

[nuget.org] Unable to load the service index for source https://api.nuget.org/v3/index.json.
  An error occurred while sending the request.
  The request was aborted: Could not create SSL/TLS secure channel.
Run Code Online (Sandbox Code Playgroud)

我已经使用 Visual Studio 和 NuGet 很长时间了,几天前 NuGet 还在工作。有人可以弄清楚为什么会发生这种情况以及我可以做些什么来解决它?

Visual Studio 2017 版本:15.9.17

visual-studio nuget

5
推荐指数
2
解决办法
6518
查看次数

如何将没有属性的 XML 转换为 JSON?

我有以下 XML 作为字符串,需要将其转换为 JSON:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope>
   <SOAP-ENV:Body>
      <Results>
         <Summary>
            <Status xsi:type="xsd:boolean">true</Status>
            <etc xsi:type="xsd:string">etc</etc>
         </Summary>
      </Results>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)

我的预期输出是:

{
  "Summary": {
    "Status": true,
    "etc": "etc"
  }
}
Run Code Online (Sandbox Code Playgroud)

我的尝试

我正在使用以下代码

var doc = new XmlDocument();
doc.LoadXml(xmlString);
var json = JsonConvert.SerializeXmlNode(doc);
var jObject = JObject.Parse(json);
var final = Convert.ToString(jObject["SOAP-ENV:Envelope"]["SOAP-ENV:Body"]["Results"]["Summary"]);
Run Code Online (Sandbox Code Playgroud)

然而,这会产生一个奇怪的 JSON,如下所示:

{
  "Status": {
    "@xsi:type": "xsd:boolean",
    "#text": "true"
  },
  "etc": {
    "@xsi:type": "xsd:string",
    "#text": "etc"
  },
}
Run Code Online (Sandbox Code Playgroud)

我应该怎么办?

序列化XmlNode

c# xml json

5
推荐指数
1
解决办法
2421
查看次数

如何在 Docker 容器内使用 Angular 模板运行 ASP.NET Core?

脚步

  1. 使用 Visual Studio 和 ASP.NET Core 以及 Angular 项目模板创建一个新项目。(其他设置:.NET 6.0、启用 HTTPS、无身份验证)

角度项目模板

  1. 添加容器编排支持(其他设置:Docker Compose、Linux)

添加容器编排支持

  1. 通过 VS 使用 Docker Compose 配置运行项目

运行项目

结果

  1. 浏览器打开,但仅显示 HTTP 404 Not Found 错误。

  2. 容器日志并没有真正的帮助。

{"EventId":60,"LogLevel":"Warning","Category":"Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository","Message":"Storing keys in a directory \u0027/root/.aspnet/DataProtection-Keys\u0027 that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.","State":{"Message":"Storing keys in a directory \u0027/root/.aspnet/DataProtection-Keys\u0027 that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.","path":"/root/.aspnet/DataProtection-Keys","{OriginalFormat}":"Storing keys in a directory \u0027{path}\u0027 …
Run Code Online (Sandbox Code Playgroud)

asp.net docker angular

5
推荐指数
0
解决办法
975
查看次数

如何解决 Angular 项目中的 Tailwind 和 Bootstrap 冲突

我在同一个 Angular 项目中使用 Tailwind CSS 和 Bootstrap (ngx-bootstrap)。大多数情况下,他们相处得很好。然而,当涉及到填充和边距时,它们就像兄弟姐妹一样互相争斗。我想使用 Tailwind 进行填充,因为它是一致的。例如,类p-X是 X 乘以 0.25 rem,但是使用 bootstrap,它就到处都是。烦人的是Bootstrap!important到处放。

utilities.css来自Tailwind,_spacing.scss来自Bootstrap。

填充3

填充4

填充5

有没有方便的方法来解决这个问题?

css user-interface bootstrap-4 tailwind-css

4
推荐指数
1
解决办法
5630
查看次数