我知道我可以在聚焦的输入元素上设置一个样式,如下所示:
input:focus
{
background-color:yellow;
}
Run Code Online (Sandbox Code Playgroud)
但是,当输入具有焦点时,是否可以在父元素上设置样式?例如
<div class="foo">
<input type="text />
Hello
</div>
Run Code Online (Sandbox Code Playgroud)
输入有焦点时,我可以影响"foo"样式吗?
编辑:影响父元素的可能重复:focus'd元素(纯CSS + HTML首选)
但是,有人可以解释这是如何工作的吗?
我正在将应用程序的输出传送到我的.NET应用程序中.
编码有点奇怪.字母ÅÄÖ显示为├Ñ├ñ├
我试图从各种不同的编码来回转换,没有任何成功.任何人都知道如何在这里正确转换字符串?
例如,应用程序的文档说输出是UTF8,所以我试过这个:
byte[] encodedBytes = Encoding.UTF8.GetBytes(theOutput);
var res = Encoding.Default.GetString(encodedBytes);
Run Code Online (Sandbox Code Playgroud)
哪个不正确的结果.
编辑:代码:
var processStartInfo = new ProcessStartInfo
{
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardInput = true,
UseShellExecute = false,
Arguments = a,
FileName = path + "\\phantomjs.exe"
};
var process = new Process
{
StartInfo = processStartInfo,
EnableRaisingEvents = true
};
//capturing output here
process.OutputDataReceived +=
(sender, args) => outputBuilder.Append(args.Data);
process.Start();
process.BeginOutputReadLine();
process.WaitForExit(20000);
process.CancelOutputRead();
Run Code Online (Sandbox Code Playgroud) 使用TPL.DataFlow块,是否可以将两个或多个源链接到单个ITargetBlock(例如ActionBlock)并确定源的优先级?
例如
BufferBlock<string> b1 = new ...
BufferBlock<string> b2 = new ...
ActionBlock<string> a = new ...
//somehow force messages in b1 to be processed before any message of b2, always
b1.LinkTo (a);
b2.LinkTo (a);
Run Code Online (Sandbox Code Playgroud)
只要b1中有消息,我希望这些消息被输入"a",一旦b1为空,b2消息就被推送到"a"
想法?
是否可以使用System.Threading.Task.Task创建可以取消的任务循环?
流程应以Task.Delay(x ms)开始,然后继续使用用户定义的任务,然后是另一个Task.Delay(y ms),并从用户定义的任务开始重复.
var result = Task.Delay(initialDelay)
.ContinueWith(t => dostuff..)
.ContinueWith what goes here?
Run Code Online (Sandbox Code Playgroud)
甚至可以使用任务吗?
我可以启动一个计时器并完成它,但如果我需要取消,使用任务似乎是正确的方法,不是吗?
在阅读有关HATEOAS /超媒体约束的内容时,我经常看到的一件事是资源应该具有某种类型的self/href.对此的论点是客户端不应该知道如何构造该特定资源的URL,例如用于更新资源.
例如
{
//instead of "id":"123"
"href":"/api/v1/orders/123",
order state...
}
Run Code Online (Sandbox Code Playgroud)
我喜欢这个主意.
但是这个概念如何适合获取数据?假设我需要获取具有特定订单ID的订单,客户将如何处理该订单?在这种情况下,我仍然需要知道如何构造资源的URL,对吧?
客户端应该如何知道查找资源的位置和方式?它必须以某种方式了解API URL?
我想使用LINQ表达式设置私有字段。我有以下代码:
//parameter "target", the object on which to set the field `field`
ParameterExpression targetExp = Expression.Parameter(typeof(object), "target");
//parameter "value" the value to be set in the `field` on "target"
ParameterExpression valueExp = Expression.Parameter(typeof(object), "value");
//cast the target from object to its correct type
Expression castTartgetExp = Expression.Convert(targetExp, type);
//cast the value to its correct type
Expression castValueExp = Expression.Convert(valueExp, field.FieldType);
//the field `field` on "target"
MemberExpression fieldExp = Expression.Field(castTartgetExp, field);
//assign the "value" to the `field`
BinaryExpression assignExp = Expression.Assign(fieldExp, …Run Code Online (Sandbox Code Playgroud) 在Akka和Akka.Net中,有用于处理异步内容(如I/O)的PipeTo模式,并将消息传递回actor的消息框.如何在Protoactor中完成?
我正在尝试使用 MS Graph API 读取特定邮箱中的电子邮件。
var client = await GetClient(); //getting a client with client id, secret
var users = await client.Users.Request()
.Filter("startswith(displayName,'roger')")
.GetAsync(); //getting the users matching a criteria
var user = users.First(); //get the first user
//log the user name, this works fine
log.LogInformation("Found user " + user.DisplayName);
//this is null
var messages = user.MailFolders?.FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)
我从此处获取的用户那里获得了所有正确的数据,但用户mailFolders属性是null.
为什么是这样?
我们想要扫描特定邮箱中的电子邮件并处理这些电子邮件和附件。我认为这可能是做到这一点的正确方法。但我坚持上述内容,MS Graph 的文档,尤其是 .NET API 的文档也很一般。
这是一个权限的事情,我可以通过某种方式增加我们AD应用程序注册的权限来获得这个权限吗?
还是还有其他事情发生?
我正在观看有关Async CTP的视频,并看到如果你从主线程调用等待,那么当工作完成时执行将从主线程继续.
例如
//called from main thread
var result = await SomeAsyncWork();
//this will execute in main thread also
console.writeline(result)
Run Code Online (Sandbox Code Playgroud)
我有一种天真的印象,即会有一个正常的回调,它会在工作线程上执行.
在某种程度上,必须是正在发生的事情,因为你可以使用Task.FromAsync在T的任务中包装普通的异步方法
但正常的异步方法将在工作线程中运行,那么如何将workerthread中的回调编组回主线程?
我刚刚开始摆弄 Erlang。我见过很多在函数声明中使用模式匹配的例子,如下所示:
factorCount (N) ->
Sqrt = math:sqrt (N),
ISqrt = trunc(Sqrt),
if ISqrt == Sqrt -> factorCount (N, ISqrt, 1, -1);
true -> factorCount (N, ISqrt, 1, 0)
end.
factorCount (_N, ISqrt, Candidate, Count) when Candidate > ISqrt -> Count;
factorCount ( N, ISqrt, Candidate, Count) ->
case N rem Candidate of
0 -> factorCount (N, ISqrt, Candidate + 1, Count + 2);
_ -> factorCount (N, ISqrt, Candidate + 1, Count)
end.
Run Code Online (Sandbox Code Playgroud)
为什么要这样做?。例如
factorCount (_N, ISqrt, Candidate, Count) …Run Code Online (Sandbox Code Playgroud) c# ×6
.net ×2
async-ctp ×1
c#-5.0 ×1
css ×1
css3 ×1
erlang ×1
hateoas ×1
html5 ×1
hypermedia ×1
proto.actor ×1
reflection ×1
rest ×1
syntax ×1
tpl-dataflow ×1
utf-8 ×1