SpecFlow writes its output into Console like this:
Given the "TestOperator" user is logged in
-> done: WebUserSteps.GivenTheUserIsLoggedIn("TestOperator", "") (9.5s)
Run Code Online (Sandbox Code Playgroud)
How can we make it use NLog to configure where it should write?
With this:
public class CustomListener : ITraceListener
{
private Logger Log = LogManager.GetLogger("SPECFLOW");
public void WriteTestOutput(string message)
{
Log.Trace(message);
}
public void WriteToolOutput(string message)
{
Log.Trace(message);
}
}
Run Code Online (Sandbox Code Playgroud)
And
[Binding]
public class ScenarioContextInitializer
{
private readonly IObjectContainer _container;
public ScenarioContextInitializer(ScenarioContext scenarioContext)
{
_container = (scenarioContext ?? throw …Run Code Online (Sandbox Code Playgroud) 它是否加载此代码中的所有记录或使用类似SqlDataReader的内容?
using (var c = new SqlConnection(_options.TargetConnectionString))
{
c.Open();
foreach(var record in c.Query("select * from Users")) // suppose N+1 records
{
// all records loaded or read one by one here?
// some work here...
}
}
Run Code Online (Sandbox Code Playgroud) 我已使用 AzCopy 实用程序将一个大型 zip 存档上传到 Azure 存储 BLOB 容器(约 9GB)。现在我想检查它是否正确。我可以从 Azure 门户获取文件的“CONTENT-MD5”值。然后我需要在我这边计算这个,对吗?有没有其他方法来检查有效性(除了下载这个文件)?它是使用 7zip 实用程序存档的,该实用程序没有用于 MD5 的哈希算法。
为什么整数数组不是对象数组?为什么“object[]”类型的模式不能用于“int[]”?
1 is object
True
new int[10] is object
True
new int[10] is object[] // Why?
False
(Array)new int[10] is object[]
False
(Array)new object[10] is object[]
True
new object() is object
True
new object[10] is object
True
new object[10] is object[]
True
int[] arr = new int[10];
// Why the compilation error?
// error CS8121: An expression of type 'int[]' cannot be handled by a pattern of type 'object[]'
if (arr is object[] objArr)
Console.WriteLine(objArr);
// And this works:
if …Run Code Online (Sandbox Code Playgroud) Asp.net Mvc 5.2,SignalR 2.1,MS Owin(Katana)3.0的Autofac 3.5配置应该是什么?注册Autofac解析器的方法是否不那么复杂(现在有两个)?或者为什么ILifetimeScope我的中心不可见?
例外:
Autofac.Core.DependencyResolutionException:在类型'OperatorHub'上调用构造函数'Void .ctor(Autofac.ILifetimeScope)'时抛出异常.--->
从请求实例的作用域中看不到具有匹配"AutofacWebRequest"的标记的作用域.这通常表示SingleInstance()组件(或类似场景)正在请求注册为每HTTP请求的组件.在Web集成下,始终从DependencyResolver.Current或ILifetimeScopeProvider.RequestLifetime请求依赖项,从不从容器本身请求.(详见内部异常.)--->
Autofac.Core.DependencyResolutionException:从请求实例的作用域中看不到具有匹配'AutofacWebRequest'的标记的作用域.这通常表示SingleInstance()组件(或类似场景)正在请求注册为每HTTP请求的组件.在Web集成下,始终从DependencyResolver.Current或ILifetimeScopeProvider.RequestLifetime请求依赖项,从不从容器本身请求.
在我的OwinStartup中(请参阅owin中的autofac + mvc owin和autofac + signalr):
public void Configuration(IAppBuilder app)
{
var builder = new ContainerBuilder();
// ... registration. There is .InstancePerRequest() and .SingleInstance()
Autofac.Integration.Mvc.RegistrationExtensions.RegisterControllers(builder,typeof(MvcApplication).Assembly);
Autofac.Integration.SignalR.RegistrationExtensions.RegisterHubs(builder, Assembly.GetExecutingAssembly());
var container = builder.Build();
// 1st resolver
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
app.UseAutofacMiddleware(container);
app.UseAutofacMvc();
// yet the 2nd resolver!
app.MapSignalR(new HubConfiguration { Resolver = new Autofac.Integration.SignalR.AutofacDependencyResolver(container) });
}
Run Code Online (Sandbox Code Playgroud)
枢纽:
public class OperatorHub : Hub
{
public OperatorHub(ILifetimeScope hubLifetimeScope)
{ …Run Code Online (Sandbox Code Playgroud) 为什么Enable-PSRemoting/ Set-WSManQuickConfig无法在Windows 2012R2,Azure WebRole的管理员下运行“检查防火墙的状态”?如何解决这个问题?
PS D:\Users\***User> enable-psremoting -force
WinRM is already set up to receive requests on this computer.
Set-WSManQuickConfig : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2"
Machine="localhost"><f:Message><f:ProviderFault provider="Config provider"
path="%systemroot%\system32\WsmSvc.dll"><f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault"
Code="2" Machine="RD***CA2"><f:Message>Unable to check the status of the firewall.
</f:Message></f:WSManFault></f:ProviderFault></f:Message></f:WSManFault>
At line:69 char:17
+ Set-WSManQuickConfig -force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Set-WSManQuickConfig], InvalidOperationException
+ FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.SetWSManQuickConfigCommand
Run Code Online (Sandbox Code Playgroud)
操作系统名称:Microsoft Windows Server 2012 R2数据中心。操作系统版本:6.3.9600 N / A Build 9600. Powershell:4.0
PS。是的,有:
我尝试了几种方法来使它工作,但似乎没有简单的方法。是的,有大量的插件和配置。但根据 2019 年 10 月,它们无法正常工作。
所以这似乎 csharpers 应该去 VS(或 Rider),那是 MS 提出 LSP 的时候。你如何让 IDE 像 nvim 一样与 C# 一起工作?
基本上客户端应该像这样启动服务器并使用 LSP。
~/.cache/omnisharp-vim/omnisharp-roslyn/run -s <PATH TO SLN OR DIR>
Run Code Online (Sandbox Code Playgroud) 请看这段代码:
using System;
using System.Linq;
public class Test {
public static void Main() {
var s = "5401";
Console.WriteLine(s);
var predicate = (d,i) => {
var r = i > 0 ? s[i-1] >= s[i] : true;
Console.Write($"{i}: {s[i]}; ");
if(i > 0) Console.Write($"{i-1}: {s[i-1]};");
Console.WriteLine($" result: {r}");
return r;
};
Console.WriteLine(new String(s.TakeWhile(predicate).ToArray()));
// the case:
Console.WriteLine(new String(s.Reverse().TakeWhile(predicate).ToArray()));
}
}
Run Code Online (Sandbox Code Playgroud)
它输出:
5401
0: 5; result: True
1: 4; 0: 5; result: True
2: 0; 1: 4; result: True
3: 1; …Run Code Online (Sandbox Code Playgroud)