我有一个控制台应用程序(在网络核心1.1中),它每隔1分钟在cron调度程序中安排一次.在应用程序内部有调用配置文件.我附上下面的代码.
public static T GetAppConfig<T>(string key, T defaultValue = default(T))
{
T value = default(T);
logger.Debug($"Reading App Config {key}");
try
{
var environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var builder = new ConfigurationBuilder()
.AddJsonFile($"appsettings.json", true, true)
.AddJsonFile($"appsettings.{environmentName}.json", true, true)
.AddEnvironmentVariables();
var configuration = builder.Build();
T setting = (T)Convert.ChangeType(configuration[key], typeof(T));
value = setting;
if (setting == null)
value = defaultValue;
}
catch (Exception ex)
{
logger.Warn(ex, $"An exception occured reading app key {key} default value {defaultValue} applied.");
value = defaultValue;
}
return value;
} …Run Code Online (Sandbox Code Playgroud) 我的路由器配置如下所示。
const routes: Routes = [
{
path: 'Registration',
component: RegisterComponent,
children: [
{ path:'',component:ProfileComponent},
{ path: 'Dependent', component: DependentComponent },
{ path: 'Matrimony', component: MatrimonyComponent },
{ path: 'Subscription', component: MagazinesubscriptionComponent },
{ path: 'Donation', component: DonationComponent }
]
},
{
path: 'Profile',
component: ProfilelistComponent
//component: VoteprofileComponent
}
];
Run Code Online (Sandbox Code Playgroud)
我想用这个路由器进行编辑。意思如下图所示。
const routes: Routes = [
{
path: 'Registration/:id',
component: RegisterComponent,
children: [
{ path:'',component:ProfileComponent},
{ path: 'Dependent', component: DependentComponent },
{ path: 'Matrimony', component: MatrimonyComponent },
{ path: 'Subscription', …Run Code Online (Sandbox Code Playgroud) 我有一个如下所示的打字稿。
enum Categories {
textbox = 1,
password
}
let typedata:string ="textbox";
let enumdata:Categories;
Run Code Online (Sandbox Code Playgroud)
我想将此文本框字符串转换为枚举。这样我就可以在enumdata变量中分配它。当我尝试使用
enumdata=Categories[typedata]
Run Code Online (Sandbox Code Playgroud)
我遇到错误
元素隐式具有“ any”类型,因为索引表达式不是“ number”类型
如果有人遇到此问题,请告诉我。如果您找到解决方法,请提供示例。
我的打字稿版本是2.6.2
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": [
"dom",
"es2015"
],
"noImplicitAny": false,
"sourceMap": true,
"rootDir": "src",
"outDir": "dist",
"noEmitOnError": true
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢Vipin
我想知道 Task.delay Task.Wait 和 Thread.sleep 之间的区别
当我们使用thread.sleep时。从睡眠中唤醒后,将创建一个新堆栈。请让我告诉我它们之间真正的区别是什么。