小编Vip*_*pin的帖子

在dotnet核心中读取json文件时出错"已达到inotify实例数量的已配置用户限制(128)"

我有一个控制台应用程序(在网络核心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)

c# .net-core asp.net-core .net-standard

8
推荐指数
2
解决办法
5754
查看次数

如何在 Angular 7 中创建可选的路由器参数

我的路由器配置如下所示。

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)

typescript angular angular-router

5
推荐指数
1
解决办法
1万
查看次数

元素隐式地具有“ any”类型,因为在打字稿中将字符串转换为enum时,索引表达式不是enum的“ number”类型

我有一个如下所示的打字稿。

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

typescript

4
推荐指数
1
解决办法
2268
查看次数

task.wait 、 Task.delay 和 thread.sleep 之间的区别

我想知道 Task.delay Task.Wait 和 Thread.sleep 之间的区别

当我们使用thread.sleep时。从睡眠中唤醒后,将创建一个新堆栈。请让我告诉我它们之间真正的区别是什么。

task-parallel-library c#-4.0

1
推荐指数
1
解决办法
6301
查看次数