在C#6.0中我可以写:
public int Prop => 777;
Run Code Online (Sandbox Code Playgroud)
但我想使用getter和setter.有办法做下一件事吗?
public int Prop {
get => propVar;
set => propVar = value;
}
Run Code Online (Sandbox Code Playgroud) 我有异步方法的一次性类。
class Gateway : IDisposable {
public Gateway() {}
public void Dispose() {}
public async Task<Data> Request1 () {...}
public async Task<Data> Request2 () {...}
public async Task<Data> Request3 () {...}
}
Run Code Online (Sandbox Code Playgroud)
我需要 Dispose 等待所有正在运行的请求完成。
那么,要么我需要跟踪所有正在运行的任务,要么使用AsyncLockAsyncEx 或其他东西?
更新
正如我所看到的,有人害怕阻止 Dispose。然后我们可以制作Task WaitForCompletionAsync()或Task CancelAllAsync()方法。
在0.5版本中很容易:
<polymer-element name="textarea-tpl" attributes="value placeholder">
<template>
<link rel="stylesheet" type="text/css" href="css/index.css">
<textarea id="textarea" value="{{value}}" placeholder="{{placeholder}}"></textarea>
<textarea id="hidden_textarea"></textarea>
</template>
<script>
Polymer({
ready: function() {
var text = this.$.textarea;
var hidden_text = this.$.hidden_textarea;
text.onkeyup = function() {
hidden_text.value = text.value + "\n";
var height = hidden_text.scrollHeight;
text.style.height = height+'px';
};
}
});
</script>
</polymer-element>
Run Code Online (Sandbox Code Playgroud)
在1.0版本中,此绑定不起作用.只写一次作品而且很奇怪,只有一次.v1.0的代码:
<dom-module id="chat-textarea">
<template>
<textarea id="textarea" value="{{value}}" placeholder="{{placeholder}}"></textarea>
<textarea id="hidden_textarea"></textarea>
</template>
<script>
Polymer({
is: "chat-textarea",
properties: {
value: String,
placeholder: String
},
set text(val) {
this.$.textarea.value = val;
}, …Run Code Online (Sandbox Code Playgroud) 我正试图通过以下方式打印消息:
Console.WriteLine( "Hello World!" );
loggerFactory.MinimumLevel = LogLevel.Debug;
loggerFactory.AddConsole( LogLevel.Debug );
var logger = loggerFactory.CreateLogger("Startup");
logger.LogWarning( "Hi!" );
Run Code Online (Sandbox Code Playgroud)
但是我在哪里可以看到这些消息?
输出窗口不包含此消息.
如果我将项目作为Web运行,它会运行dnx控制台,在那里我可以看到这些消息.但这不方便.
但是,如果我将项目作为IIS Express运行,我看不到也没有控制台,也没有消息.
有没有办法在Visual Studio中查看此消息?
例:
class Base<T>{}
class Child<T> : Base<T>{}
typeof( Base<> ).IsGenericTypeDefinition; // == true ie. parameterless
typeof( Child<> ).BaseType.IsGenericTypeDefinition; // == false wtf???
// Eventually
typeof( Base<> ) != typeof( Child<> ).BaseType;
Run Code Online (Sandbox Code Playgroud)
由于此功能typeof( Child<> ).IsSubclassOf( typeof( Base<> ) )不起作用.
这是默认的 VSPackage。我只添加了 ProvideAutoLoad 属性。
using System;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.Win32;
using Task = System.Threading.Tasks.Task;
namespace VSIXProject1
{
/// <summary>
/// This is the class that implements the package exposed by this assembly.
/// </summary>
/// <remarks>
/// <para>
/// The minimum requirement for a class to be considered a valid package for Visual Studio
/// is to implement the IVsPackage …Run Code Online (Sandbox Code Playgroud) 我是 NLog 新手,对布局和布局渲染器感到困惑。
我看到以下代码\页面:
https://github.com/NLog/NLog/wiki/Configuration-API
Layout = @"${date:format=HH\:mm\:ss} ${level} ${message} ${exception}"
https://github.com/NLog/NLog/wiki/Exception-Layout-Renderer(类似于第一个)
我明白第一个(日志消息的格式),但第二个和第三个我不明白。
c# ×3
.net ×2
asp.net ×1
asp.net-core ×1
async-await ×1
asynchronous ×1
c#-6.0 ×1
generics ×1
iis-express ×1
javascript ×1
nlog ×1
polymer ×1
polymer-1.0 ×1
vsix ×1
vssdk ×1