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

  • 相关阅读:
    LeetCode:Container With Most Water
    c#编写的基于Socket的异步通信系统
    关于Thread类中三个interrupt方法的研究与学习(转)
    使用svnkit 的相关实例及相关问题汇总
    创业早期,联合创始人如何避免窝里反?(转)
    程序员解决问题的60个策略(转)
    码农和程序员之间的5个关键差异(转)
    LayoutInflater的使用
    2014年中国95家企业入围世界500强,超日本
    How to get the source code of the chromium of the specified revision
  • 原文地址:https://www.cnblogs.com/yudongdong/p/11745725.html
Copyright © 2011-2022 走看看