小编can*_*cat的帖子

如何使用 FileSystemGlobbing.Matcher

如何使用该类Microsoft.Extensions.FileSystemGlobbing.Matcher。我阅读了文档,但我仍然不明白。

我希望能够排除指定的文件夹(使用 glob),但代码不起作用:

var matcher = new Matcher();
matcher.AddExclude("foo/*.txt");
matcher.Match(new[] { "foo/a.txt", "foo/b.md", "bar/a.txt" }); // HasMatches: false
Run Code Online (Sandbox Code Playgroud)

预期的:

foo/b.md
bar/a.txt
Run Code Online (Sandbox Code Playgroud)

实际的:

// nothing
Run Code Online (Sandbox Code Playgroud)

.net c#

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

Consul代理和目录的区别

我不明白 consulxe2x80x99s agentapi 和consulxe2x80x99s api 之间的区别catalogapi

\n

虽然consul文档一直强调agent和catalog不要混淆\xef\xbc\x8c,但是确实有很多看起来类似的方法,比如:

\n\n

我什么时候应该使用catalogagent\xef\xbc\x88 就像上面的 http url\xef\xbc\x89 一样?

\n

哪一种适合高频次通话?

\n

consul

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

执行由 dotnet publish 发布的程序集时找不到依赖项

我编写了一个 .NET Core 2.0 控制台应用程序。使用 发布dotnet publish,但是执行过程中出现错误:

运行失败

编译项目

dotnet publish src\Bucket.CLI\Bucket.CLI.csproj -c Release --self-contained false
Run Code Online (Sandbox Code Playgroud)

执行程序

  • bin\Release\netcoreapp2.0\publish
dotnet Bucket.CLI.dll
Run Code Online (Sandbox Code Playgroud)

提示错误:

Error:
  An assembly specified in the application dependencies manifest (Bucket.CLI.dep
s.json) was not found:
    package: 'System.Text.Encoding.CodePages', version: '4.5.1'
    path: 'runtimes/win/lib/netcoreapp2.0/System.Text.Encoding.CodePages.dll'
Run Code Online (Sandbox Code Playgroud)

运行成功

但是,如果我指定 a --runtime,则不会发生错误?

编译项目

dotnet publish src\Bucket.CLI\Bucket.CLI.csproj -c Release --self-contained false -r win-x64
Run Code Online (Sandbox Code Playgroud)

执行程序

  • bin\Release\netcoreapp2.0\win-x64\publish
dotnet Bucket.CLI.dll
Run Code Online (Sandbox Code Playgroud)

该程序运行良好。

这可能是什么原因造成的?


如果我添加帖子添加:Bucket.CLI.runtimeconfig.dev.json那么程序可以成功运行。但这不起作用。还有其他方法吗?

{
  "runtimeOptions": {
    "additionalProbingPaths": [
      "C:\\Users\\menghanyu\\.dotnet\\store\\|arch|\\|tfm|",
      "C:\\Users\\menghanyu\\.nuget\\packages",
      "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

当我添加 …

c# .net-core

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

我重载了一个虚函数,但它不起作用

到目前为止,我做了以下工作:

class Stamp{
 public:
    virtual std::string GetStampName() const { return "undefined"; }
};
Run Code Online (Sandbox Code Playgroud)
class FooStamp : public Stamp {
 public:
    std::string GetStampName() const override { return "foo-stamp"; }
};
Run Code Online (Sandbox Code Playgroud)

我像这样使用它:

FooStamp fooStamp;
std::cout << "foo-stamp:" << fooStamp.GetStampName() << std::endl;

const Stamp stamp = fooStamp;
std::cout << "stamp:" << stamp.GetStampName() << std::endl;
Run Code Online (Sandbox Code Playgroud)

实际输出如下?

foo-stamp:foo-stamp
stamp:undefined     // expected: foo-stamp
Run Code Online (Sandbox Code Playgroud)

转换为基类的类型不起作用。我做错了什么。

有没有办法使覆盖有效并确保按值复制对象。

c++

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

如何优化右值参数的返回值避免复制

我正在写一个网络模块,使用的是信封模型,下面是一个sent函数,函数参数使用的是右值引用?

Envelope NatsTransport::Send(Envelope&& envelope)
{
    // do somthing...

    if (!natsConnection->Send(envelope.GetContent(), envelope.Length()))
    {
        return envelope.With<SentFaildStamp>("envelope send faild");
    }

    return envelope; // called the envelope's copy constructor
    // return std::move(envelope); // called the envelope's copy constructor
}
Run Code Online (Sandbox Code Playgroud)
template <class TStamp, typename... Args>
Envelope With(Args&&... args) const 
{
     // When the With method is called, the copy constructor of the
     // envelope is called. This is in line with the design expectations,
     // because adding stamps to the envelope will not modify the …
Run Code Online (Sandbox Code Playgroud)

c++

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

标签 统计

c# ×2

c++ ×2

.net ×1

.net-core ×1

consul ×1