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

  • 相关阅读:
    Chapter 4: Using Custom Property Types
    Chapter 2: Connecting to C++ Methods and Signals
    C++ Extensions: Reference examples
    qt exec
    qt component desktop
    Qt事件处理机制
    Tutorial: Writing QML Extensions with C++
    label for
    (一) HTTP 1.1支持的状态代码
    一些常用的特殊字符
  • 原文地址:https://www.cnblogs.com/yudongdong/p/11745725.html
Copyright © 2011-2022 走看看