我有一些表格和按钮来保存它。仅当表单上有未保存的更改(输入)时,才必须启用该按钮。
<form>
<div>
... (inputs)
<span (click)="save()"> Save </span>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
Angular 5中有一些内置的表单脏检查机制吗?实施此方案的最简单方法是什么?
我想在我的 Web API 2(net.framework 4.6.2 应用程序)中缓存静态内容(index.html)
我编写了 OWIN 中间件,它cache-control向响应添加了标头,从而允许从浏览器缓存中检索后续请求。
OWIN 上下文扩展:
public static class BrowserCacheOwinContextExtensions {
public static IOwinContext SetCacheControlHeader(this IOwinContext context, int maxAge) {
context.Response.Headers["Cache-Control"] = $"public, max-age={maxAge}";
context.Response.Headers["Vary"] = "User-Agent";
return context;
}
}
Run Code Online (Sandbox Code Playgroud)
中间件的片段:
if (browserCacheOptions.IsEnable) {
context.SetCacheControlHeader(browserCacheOptions.MaxAge);
}
await context.Response.WriteAsync(file);
Run Code Online (Sandbox Code Playgroud)
它在 Mozilla 浏览器中工作正常,但在 Chrome 中却不行。
来自 Mozilla 的片段:
我相信其根本原因是 Chrome自动向请求添加了额外的Sec-Fetchheaders + 。cache-control: max-age=0
Chrome 自动添加 Sec-Fetch 标头:
注意:如果在单独的浏览器选项卡中打开相同的请求,则它在 Chrome 中工作正常(sec-fetch请求中没有标头)
问:是否可以以某种方式禁用此类行为,并且不自动将 sec-fetch 标头添加到请求中?
或者如果您有其他建议,请分享。
我有一个问题)
我尝试在我的c#代码中重现类似几个sp(存储过程)调用的东西,但我想以异步方式执行它.
TSQL示例:( Execute sp @key = 15072000173475; Execute sp @key = 15072000173571; ... Execute sp @key = n;)
[TestClass]
public class UnitTestNomenclature {
[TestMethod]
public void ParallelSQLMethod() {
Task scropeTasks = null;
//real amount is more then 1500
long[] keys = new long[] {15072000173475,15072000173571 ... n };
try {
var tasks = keys.Select( i => Task.Run(async () => { await RunStoredProc(i); }));
scropeTasks = Task.WhenAll(tasks);
scropeTasks.Wait();
} catch (Exception ex) {
Debug.WriteLine("Exception: " + ex.Message);
Debug.WriteLine("IsFaulted: " + …Run Code Online (Sandbox Code Playgroud) 您好我正在努力重构一些遗留代码.有些代码表示从自定义类型到c#类型的"转换器".
...
if (dataType == CustomType.Bit)
{
return typeof(bool);
}
else if (dataType == CustomType.Bittype ||
dataType == CustomType.Char ||
dataType == CustomType.Fromtotype ||
dataType == CustomType.Mdcintervaltype ||
dataType == CustomType.Nclob ||
dataType == CustomType.Nchar ||
dataType == CustomType.Ntext ||
dataType == CustomType.Nvarchar ||
dataType == CustomType.Nvarchar2 ||
dataType == CustomType.Varchar ||
dataType == CustomType.Varchar2)
{
return typeof(string);
}
else if (dataType == CustomType.Date ||
dataType == CustomType.Datetime ||
dataType == CustomType.Timestamp3 ||
dataType == CustomType.Timestamp6)
{
return typeof(DateTime);
} …Run Code Online (Sandbox Code Playgroud) 我有一个.net core后台代理(托管服务)
它使用 Web 作业触发功能处理 Azure 服务总线消息
public async Task ProcessSyncResponseMessage(
[ServiceBusTrigger(ServiceBusTriggers.SyncResponses, ServiceBusTriggers.SubscriptionName)] Message message)
{
// some actions
}
Run Code Online (Sandbox Code Playgroud)
正如我所看到的,它在PeekLock 模式下工作,但我想切换到ReceiveAndDelete 模式,从而在收到消息后立即从服务总线中删除消息。
我想知道是否可以使用 .net core web 作业触发功能。
问:如果是这样,您能给我一些提示吗?我该如何设置?
我有一段代码以异步方式写入内存流(.NET Standard 2.1)
代码:
await using var memoryStream = new MemoryStream();
await using var writer = new StreamWriter(memoryStream);
var recordTasks = stringRecordsToWrite.Select(r => writer.WriteLineAsync(r));
await Task.WhenAll(recordTasks);
await writer.FlushAsync();
var result = memoryStream.ToArray();
Run Code Online (Sandbox Code Playgroud)
问题
有几个问题困扰着我:
或者那些都是假痕迹,而且实现得很好,我应该尝试在其他地方找到原因
Ps代码片段,用于尝试重现该问题,但是,结果文件大小约为 250 MB,并且仍然没有该问题的证据......
internal class Program
{
public static async Task Main(string[] args)
{
var records = new Dictionary<string, IEnumerable<RecordsToWrite>>();
for (var i = 0; i < 200; i++)
{
var recordKey = $"test-{i}";
records.Add(recordKey, default); …Run Code Online (Sandbox Code Playgroud) c# ×3
async-await ×2
asynchronous ×2
.net-core ×1
ado.net ×1
algorithm ×1
angular ×1
angular5 ×1
azure ×1
caching ×1
collections ×1
html ×1
http-headers ×1
javascript ×1
owin ×1
servicebus ×1
streamwriter ×1
unit-testing ×1