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

  • 相关阅读:
    Celery ---- 分布式队列神器 ---- 入门
    如何使用Python快速制作可视化报表----pyecharts
    django 使用 可视化包-Pyechart
    git & github 快速入门
    开发效率进阶
    windows编译 obs-studio
    python 控制vbox虚拟机
    pyqt实践——从裸机到打包安装
    测试darwin calendar 服务器
    centos 搭建 darwin calendar 服务器
  • 原文地址:https://www.cnblogs.com/yudongdong/p/11745725.html
Copyright © 2011-2022 走看看