小编Ale*_*xei的帖子

为每个渲染上下文调用glewInit一次?或整个应用程序一次?

我有一个关于如何(正确)使用的问题glewInit().

假设我有一个多窗口应用程序,我应该glewInit()在应用程序(即全局)级别调用一次吗?或调用glewInit()每个窗口(即每个OpenGL渲染上下文)?

opengl glew

9
推荐指数
1
解决办法
2721
查看次数

Angular 5小吃店通知

我想实现像这样的通知消息

"Success! Your Details Added"
"Warning! Something Went Wrong"
"Danger! You don't have access to this"
Run Code Online (Sandbox Code Playgroud)

我已经在我的应用程序中使用角度材料我可以使用'snack-bar'进行通知吗?

我也在npm找到了一些相关的烤面包机

建议我是否有另一种方法来做到这一点.

notifications toast angular-material angular

9
推荐指数
4
解决办法
2万
查看次数

如何通过企业代理使用 OpenAPI 生成器?

我正在尝试使用OpenAPI 生成器根据openapi: "3.0.2"json 配置自动生成 C# 客户端代码:

openapi-generator generate -i https://test.com/docs/swagger/openapi.json -g csharp-netcore -c open-api-config.json -o DataLakeOpenApiRestClient.cs
Run Code Online (Sandbox Code Playgroud)

此操作失败并出现以下错误:

[主要] 错误 io.swagger.v3.parser.util.RemoteUrl - 无法读取 java.net.ConnectException:连接超时:在 java.net.DualStackPlainSocketImpl.socketConnect 处连接 java.net.DualStackPlainSocketImpl.connect0(本机方法) (未知来源) 在 java.net.AbstractPlainSocketImpl.doConnect(未知来源) 在 java.net.AbstractPlainSocketImpl.connectToAddress(未知来源) 在 java.net.AbstractPlainSocketImpl.connect(未知来源) 在 java.net.PlainSocketImpl.connect(未知来源)源)在 java.net.SocksSocketImpl.connect(未知源) 在 java.net.Socket.connect(未知源) 在 sun.security.ssl.SSLSocketImpl.connect(未知源) 在 sun.security.ssl.BaseSSLSocketImpl.connect (未知来源) 在sun.net.NetworkClient.doConnect(未知来源) 在sun.net.www.http.HttpClient.openServer(未知来源) 在sun.net.www.http.HttpClient.openServer(未知来源) 在sun .net.www.protocol.https.HttpsClient.(未知来源) 在sun.net.www.protocol.https.HttpsClient.New(未知来源) 在sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(未知来源) )在sun.net.www.protocol.http.HttpURLConnection.plainConnect0(未知来源)在sun.net.www.protocol.http.HttpURLConnection.plainConnect(未知来源)在sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection。连接(未知来源)在sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(未知来源)在io.swagger.v3.parser.util.RemoteUrl.urlToString(RemoteUrl.java:147)在io.swagger.v3 .parser.OpenAPIV3Parser.readWithInfo(OpenAPIV3Parser.java:123) 在 io.swagger.v3.parser.OpenAPIV3Parser.readLocation(OpenAPIV3Parser.java:45) 在 io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:16) 在org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:586) 在 org.openapitools.codegen.cmd.Generate.run(Generate.java:395) 在 org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.爪哇:60)

但是,如果我下载 json 文件并使用本地文件输入运行,则它可以正常工作:

openapi-generator generate -i open-api-offline-file.json -g csharp-netcore -c open-api-config.json -o DataLakeOpenApiRestClient.cs
Run Code Online (Sandbox Code Playgroud)

我在没有公司代理的计算机上对此进行了测试,它工作正常,所以我的主要怀疑是代理。

我已经设置 …

c# proxy openapi-generator

8
推荐指数
1
解决办法
7455
查看次数

分析文本(词形还原,编辑距离)

我需要分析文本中存在的禁止词.假设黑名单是单词:"禁止".这个词有很多种形式.在文本中,这个词可以是,例如:"禁止","禁止","禁止".为了将单词带到初始​​形式,我使用了一个过程词形还原.你的建议?

错别字怎么办?
例如:"F0rb1d".我认为使用damerau-Levenshtein或其他人.你的建议?

如果文本写成如下:
"ForbiddenInformation.Privatecorrespondenceofcompany." 或"F0rb1dden1nformation.Privatecorresp0ndenceofthec0mpany." (是的,没有空格)

如何解决这个问题呢?
优选地是快速算法,因为文本是实时处理的.
也许是什么提高性能的提示(如何存储等)?

对不起我的英语不好.谢谢.

c# nlp similarity lemmatization

7
推荐指数
1
解决办法
2020
查看次数

使用 ASP.NET Core 3.0 和 SQL Server 2019+ 时,我什么时候应该使用 MultipleActiveResultSets=True?

我编写的大多数应用程序都不使用MultipleActiveResultSets=True,但我已经在其中几个和一些教程中看到启用了该选项。

这个SO 问题涉及相同的主题,但它已经很老了,我相信在此期间情况发生了很大变化。

OP 争论执行一些非查询,同时执行ExecuteReader. 在这种情况下,我认为这是一个糟糕的设计,因为它可能会被一些批处理样式的操作取代,也许是一个存储过程,以最大限度地减少往返次数。

当将 Entity Framework 与 ASP.NET Core 一起使用并收到与已在范围内执行某些内容的数据上下文相关的异常时,我将其视为错误,并没有考虑启用 MARS。

读了这MS文档文章我看到一个要注意的各个方面,如选项(ANSI_NULLSDATE_FORMATLANGUAGETEXTSIZE),安全性上下文,当前的数据库,状态变量(@@ERROR@@ROWCOUNT@@FETCH_STATUS@@IDENTITY)与MARS工作时启用。

此外,如果确实需要,10 年以上意味着功能更强大的服务器能够保持更多连接(缓存应该有助于减少这种需求)。

所以我想知道在使用现代 ASP.NET Core 应用程序 (3.0+) 时是否必须考虑启用 MARS。

问题:在使用 ASP.NET Core 3.0 和 SQL Server 2019+ 时,我什么时候应该使用 MultipleActiveResultSets=True?

编辑以解决反馈

我对详尽的分析不感兴趣,但有几个合适的上下文来证明是否使用 MARS 是合理的。

ASP.NET Core 应用程序中的一个典型示例是将数据库上下文作为范围(每个请求从连接池获取一个数据库连接,进行更改,通常每个请求/范围一个事务)。到目前为止,我已经将与每个连接的多个查询相关的错误视为我自己的错误,以避免 MARS,但我这样做了,但我没有真正理解原因。

sql-server sql-server-mars entity-framework-core asp.net-core

7
推荐指数
1
解决办法
2085
查看次数

如何在 VS2010 中创建发布前和发布后脚本

我想创建一个执行某些操作的脚本,然后将该站点发布到生产环境,然后在 Visual Studio 2010 中运行另一个脚本。

c# asp.net visual-studio-2010

6
推荐指数
1
解决办法
4967
查看次数

NSwag 在使用 OpenApi 3.0 JSON 文件时生成多个同名函数

我正在尝试使用 NSwag CLI 在 .NET Core 和 TypeScript 中生成客户端代码:

nswag run options.nswag
Run Code Online (Sandbox Code Playgroud)

这适用于各种 Swagger 2.0 JSON 文件,但会为 OpenApi 3.0 JSON 文件生成多个具有完全相同名称的函数。

我的 options.swag 文件具有以下 .NET 内容(TypeScript 以类似的方式生成并遇到相同的问题):

{
  "runtime": "NetCore21",
  "defaultVariables": null,
  "documentGenerator": {
    "fromDocument": {
      "url": "https://somedomain.com/openapi.json",
      "output": null
    }
  },
  "codeGenerators": {
    "openApiToCSharpClient": {
      "clientBaseClass": null,
      "configurationClass": null,
      "generateClientClasses": true,
      "generateClientInterfaces": false,
      "injectHttpClient": true,
      "disposeHttpClient": true,
      "protectedMethods": [],
      "generateExceptionClasses": true,
      "exceptionClass": "ClientApiException",
      "wrapDtoExceptions": true,
      "useHttpClientCreationMethod": false,
      "httpClientType": "System.Net.Http.HttpClient",
      "useHttpRequestMessageCreationMethod": false,
      "useBaseUrl": true,
      "generateBaseUrlProperty": true,
      "generateSyncMethods": false,
      "exposeJsonSerializerSettings": false, …
Run Code Online (Sandbox Code Playgroud)

openapi nswag

6
推荐指数
1
解决办法
1万
查看次数

如何允许从本地主机和容器到 ASP.NET Core Web API 应用程序的 HTTPS 连接?

我正在尝试将 Docker 用于现有应用程序,但遇到以下问题。当 API 尝试从容器中获取 Identity Server 元数据时,它失败并显示以下内容:

web_api          | System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'https://host.docker.internal:5500/.well-known/openid-configuration'.
web_api          |  ---> System.IO.IOException: IDX20804: Unable to retrieve document from: 'https://host.docker.internal:5500/.well-known/openid-configuration'.
web_api          |  ---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
web_api          |  ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure. 
Run Code Online (Sandbox Code Playgroud)

这确实由主机浏览器确认(Chrome 中的认证错误)。

如果我使用 localhost 而不是 host.docker.internal 访问相同的元数据,它会按预期工作。

我已使用此处的说明来创建和信任身份服务器也使用的本地主机证书:

dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p { password here }
dotnet dev-certs https …
Run Code Online (Sandbox Code Playgroud)

https ssl-certificate docker asp.net-core

6
推荐指数
1
解决办法
1931
查看次数

Typescript 对类型参数类的泛型约束

如何对 TypeScript 类型参数施加约束。在 c# 中,您可以使用构造{ where T:class}?

type-constraints typescript

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

使用临时表的SQL Server连接上下文不能在使用SqlDataAdapter.Fill调用的存储过程中使用

我想为任何存储过程提供一些信息,例如当前用户.按照此处指出的临时表方法,我尝试了以下方法:

1)打开连接时创建临时表

        private void setConnectionContextInfo(SqlConnection connection)
        {
            if (!AllowInsertConnectionContextInfo)
                return;

            var username = HttpContext.Current?.User?.Identity?.Name ?? "";

            var commandBuilder = new StringBuilder($@"
CREATE TABLE #ConnectionContextInfo(
    AttributeName VARCHAR(64) PRIMARY KEY, 
    AttributeValue VARCHAR(1024)
);

INSERT INTO #ConnectionContextInfo VALUES('Username', @Username);
");

            using (var command = connection.CreateCommand())
            {
                command.Parameters.AddWithValue("Username", username);
                command.ExecuteNonQuery();
            }
        }

        /// <summary>
        /// checks if current connection exists / is closed and creates / opens it if necessary
        /// also takes care of the special authentication required by V3 by …
Run Code Online (Sandbox Code Playgroud)

sql sql-server ado.net stored-procedures temp-tables

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