zoukankan      html  css  js  c++  java
  • 【Autofac打标签模式】PropertySource和Value

    【 Autofac打标签模式】开源DI框架扩展地址:

    https://github.com/yuzd/Autofac.Annotation/wiki

    PropertySource 指定数据源

    属性说明
    Path 文件路径,看下面的说明
    OrderIndex 文件源排序,越大越先作为查找对象
    Embedded 是否为内嵌资源
    
        [PropertySource("appsettings.json")] //这行也可以直接去掉 因为和默认的一样
        [Component]
        public class Student9
        {
            [Value("${a9}")]
            public string Name { get; set; }
        }
        
    

    image

    image

    • PropertySource的path可以指定为json 和 xml 文件
    • PropertySource 如果不指定path 默认path为根目录的appsettions.json
    • 如果Path的值为 / 开头 则代表为相对于工程目录
    • 如果设定 Embedded = true 则代表path的值为 内嵌资源的文件名称
    • Path的值也可以为 文件的完整路径

    Value装配数据源里面的值

    • ${xxx} 代表从配置源里面 获取属性名称为xxx的值
    • #{xxx} 代表启动SPEL表达式,xxx里面可以嵌套${yyy}

    image

  • 相关阅读:
    httpclient用法
    JS逻辑运算符&&与||的妙用
    jackson详解
    MVC +EF+linq 多表联查
    Log4net 集成到MVC+EF框架
    Asp.net中的页面跳转及post数据
    字符串的分割操作
    线程的信号机制
    事件的标准模式
    Java网络编程
  • 原文地址:https://www.cnblogs.com/yudongdong/p/11745725.html
Copyright © 2011-2022 走看看