在我的MatchCollection中,我获得相同的匹配.像这样:
string text = @"match match match";
Regex R = new Regex("match");
MatchCollection M = R.Matches(text);
Run Code Online (Sandbox Code Playgroud)
如何删除重复的匹配,是否是最快的方式?
假设此处的"重复"表示匹配包含完全相同的字符串.
我已经在互联网上找到并尝试了许多解决方案,这应该允许我禁用我的WPF ListBox 的悬停效果,但它们似乎都不适合我.此屏幕截图显示了我想隐藏或摆脱的悬停效果:

这是我目前拥有的XAML代码(简化版):
<ListBox ItemsSource="{Binding Logs}" Grid.Column="1" Width="800" Height="100" >
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Style.Triggers>
<Trigger Property="Control.IsMouseOver" Value="True">
<Setter Property="Control.Background" Value="Transparent" />
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
但是,由于某种原因,它似乎对我不起作用.我的父ListBox(背景中的那个)或其他控件是否可以通过任何机会覆盖它的childs样式?(我已经尝试覆盖父母的风格)
任何帮助将受到高度赞赏.:(
在我拥有的继承项目中,我试图获取构建命令来构建Production.
我试图更改script部分中的别名package.json以传递额外的变量,例如--dev和--configuration=dev无济于事。
该项目有这些json数据文件:
env.dev
env.development
env.production
Run Code Online (Sandbox Code Playgroud)
有我运行的package.json这个构建别名:build:devnpm run build:dev
"scripts": {
"start": "NODE_ENV=dev && react-scripts start",
…
"build:dev": "npm run build --dev --configuration=dev && react-scripts build"
}
Run Code Online (Sandbox Code Playgroud)
这有效并构建,但仅适用于我在查看结果文件时验证的生产。
如果我env.production从目录中删除文件并运行构建命令,它会失败:
Creating an optimized production build...
Failed to compile.
Module not found: Error: Can't resolve 'polyfills' in 'C:\Work\MyProj\WebSiteName\src'
Run Code Online (Sandbox Code Playgroud)
这只是告诉我它可以polyfills在env.production文件中找到该位置的别名NODE_PATH=src/。
想法?
我创建了一个页面,其中向用户显示服务器报告的天气数据。时间保存为 UTC,如何从 Blazor 服务器应用程序显示本地用户或浏览器的时间?
嗨
有没有办法处理WPF应用程序中的所有错误异常和崩溃?我知道DispatcherUnhandledException,但它只处理UI线程中的异常,不是吗?有没有办法捕获并记录其他线程中的所有异常?和绑定错误呢?你如何在enterprice系统中实现这种要求?
我使用以下代码在我的Windows服务应用程序中创建自定义事件日志:
public ServiceConstructor()
{
InitializeComponent();
if (!EventLog.SourceExists("WinService"))
{
EventLog.CreateEventSource("WinService", "WinServiceLog");
eventLog1.Source = "WinService";
eventLog1.Log = "WinServiceLog";
}
}
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("Started");
}
Run Code Online (Sandbox Code Playgroud)
安装service.msi后,当我启动服务时,它启动然后停止.然后我在EventViewer Windows日志部分中发现以下错误:
服务无法启动.System.ArgumentException:在写入事件日志之前未设置Source属性.
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message)
at WinService.Service.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
我第一次尝试使用命名管道.在此处找到的MS文档中,它指出:
对于每次调用BeginWaitForConnection,必须只调用一次EndWaitForConnection.
所以我想成为一个优秀的小程序员并遵循文档,但是EndWaitForConnection()当我使用它时,它会无限期地挂起.
所以我把我的代码剥离到最低限度,所以看看我是否可以隔离问题而不是骰子.我已经从我写过的课程中提取了以下代码.我已修改它,以便它开始在管道连接上等待,然后立即尝试停止等待该管道连接:
private void WaitForConnectionCallBack(IAsyncResult result)
{
}
public void Start()
{
var tempPipe = new NamedPipeServerStream("TempPipe",
PipeDirection.In,
254,
PipeTransmissionMode.Message,
PipeOptions.Asynchronous);
IAsyncResult result = tempPipe.BeginWaitForConnection(
new AsyncCallback(WaitForConnectionCallBack), this);
tempPipe.EndWaitForConnection(result); // <----- Hangs on this line right here
}
Run Code Online (Sandbox Code Playgroud)
1)为什么要坚持下去EndWaitForConnection()?如果我想在收到连接之前关闭我的服务器,我怎么能基本上取消这个BeginWaitForConnection()回调?
2)我们假设我没有上述问题.如果2个客户端尝试很快连接到我的命名管道会发生什么?
我是否为每个人获得了回调调用,或者我是否必须等待接收第一个连接通知EndWaitForConnection()然后 WaitForConnectionCallBack()再次快速呼叫再次开始侦听下一个客户端?
后者对我来说似乎是一种竞争条件,因为我可能不会足够快地设置连接侦听器.
我在上下文菜单项中添加了4个菜单,如果单击开始上下文菜单项,我需要禁用该特定("开始")菜单.提前致谢.
ContextMenu conMenu1 = new ContextMenu();
public Form1()
{
InitializeComponent();
conMenu1.MenuItems.Add("Start", new System.EventHandler(this.Start_Click));
conMenu1.MenuItems.Add("Pause", new System.EventHandler(this.Pause_Click));
conMenu1.MenuItems.Add("Resume", new System.EventHandler(this.Resume_Click));
conMenu1.MenuItems.Add("Stop", new System.EventHandler(this.Stop_Click));
}
private void Start_Click(object sender, EventArgs e)
{
// Functionalities to disable start context menu item
}
Run Code Online (Sandbox Code Playgroud) 异步操作似乎不适合我喜欢编写的流畅接口.Asynchrony如何与Fluent结合使用?
示例:我有两个先前返回的方法,MyEntity但在更改为Async时效果不佳.在我异步他们之后,我必须await完成任务的结果,但我必须为每个添加的步骤执行此操作:
MyEntity Xx = await(await FirstStepAsync()).SecondStepAsync();
Run Code Online (Sandbox Code Playgroud)
一定有更好的方法.
我的aspnetcore docker项目构建,但是当我单击Docker按钮(或按F5)运行时,我得到了
Severity Code Description Project File Line Suppression State
Error MSB4018 The "PrepareForLaunch" task failed unexpectedly.
Microsoft.DotNet.Docker.CommandLineClientException: Creating network "dockercompose1627893588_default" with the default driver
Building pswebapi
Service 'pswebapi' failed to build: Get https://registry-1.docker.io/v2/microsoft/aspnetcore/manifests/1.1: unauthorized: incorrect username or password.
For more troubleshooting information, go to http://aka.ms/DockerToolsTroubleshooting ---> Microsoft.DotNet.Docker.CommandLineClientException: Creating network "dockercompose1627893588_default" with the default driver
Building pswebapi
Service 'pswebapi' failed to build: Get https://registry-1.docker.io/v2/microsoft/aspnetcore/manifests/1.1: unauthorized: incorrect username or password
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.DotNet.Docker.DockerComposeClient.<ExecuteAsync>d__18.MoveNext()
--- End of …Run Code Online (Sandbox Code Playgroud) c# ×7
.net ×2
wpf ×2
asp.net-core ×1
async-await ×1
asynchronous ×1
docker ×1
dockerhub ×1
duplicates ×1
event-log ×1
fluent ×1
interprocess ×1
localization ×1
match ×1
named-pipes ×1
node.js ×1
npm ×1
npm-scripts ×1
package.json ×1
regex ×1
server ×1
utc ×1
winforms ×1
xaml ×1