zoukankan      html  css  js  c++  java
  • ASP.NET Core 学习笔记(配置管理)

    1、命令行配置

    使用Configuration 需添加 Microsoft.AspNetCore.All ,安装完成后可 using Microsoft.Extensions.Configuration 

    Configuration以键值对的方式获取

    1) 通过应用程序参数设置Configration

    2)从内存中获取

        去除原先应用程序参数设置

       

    3)通过命令行设置参数,通过dotnet 命令运行程序

     

    2、Json文件配置

    3、使用bind 读取配置 到c# 实例

     

    该方法默认读取appsettings.json 文件加到配置文件里。 在Startup.cs 文件中使用 依赖注入 通过 IConfigration 获取配置,再使用 Configration.Bind(c# 实例对象),将配置信息映射到 c#实例对象中

    4、.net  core  使用MVC Options

    加入MVC 的依赖配置,Configure方法中使用默认路由 app.UseMvcWithDefaultRoute(); 将MVC 中间件添加到应用程序中

    HomeController 中依旧使用依赖注入的方式 获取c# 实例,使用@model 在页面中显示数据, 而在这之前需在startup.cs中注册c# 类

    也可不在Controller中使用依赖注入 直接在 页面中使用 ,这时不需要@model

    5、asp.net core MVC 支持热更新,主要实现代码是 Program.cs 文件中的WebHost.CreateDefaultBuilder(args) 方法。(结合IOptionsSnapshot 使用)

    源代码在https://github.com/aspnet/MetaPackages中 

    该静态方法默认热更新(第三个参数),该方法也可自行覆盖。

    6、配置框架简析

    自定义provider :https://www.cnblogs.com/kklldog/p/configruation_source.html

  • 相关阅读:
    tp.c
    trace
    一致性哈希算法
    update_dctcp_alpha
    dctcp-ns2-patch
    C++ inheritance: public, private. protected ZZ
    C++ virtual inheritance ZZ
    C++ 类对象的初始化顺序 ZZ
    C++ inheritance examples
    classifier.cc-recv() [ns2.35]
  • 原文地址:https://www.cnblogs.com/caolingyi/p/8871001.html
Copyright © 2011-2022 走看看