你的位置:首页 > 软件开发 > ASP.net > [Asp.net 5] Configuration

[Asp.net 5] Configuration

发布时间:2015-05-26 12:00:28
本系列文章讲的是asp.net 5(Asp.net VNext)中的配置文件部分,工程下载地址为:https://github.com/aspnet/Configuration本节讲的是Configuration解决方案中的Microsoft.Framework.Configur ...

本系列文章讲的是get='_blank'>asp.net 5(Asp.net VNext)中的配置文件部分,工程下载地址为:https://github.com/aspnet/Configuration

本节讲的是Configuration解决方案中的Microsoft.Framework.Configuration和Microsoft.Framework.Configuration.Abstractions俩个工程。

Abstractions

首先我们看下Configuration.Abstractions这个工程的详情:

[Asp.net 5] Configuration

该工程中只定义了三个接口:IConfiguration、IConfigurationBuilder、IConfigurationSource,是完全为了抽象而设计的工程。

我们在依赖注入(DependencyInjection)篇中也接触过名字为“Abstractions”的工程(链接地址:http://www.cnblogs.com/watermoon2/p/4511269.html),也是只包含必须的接口定义,我们可以推测,微软的命名规则是对于XXXX类工程:

  • Microsoft.Framework.XXXX.Abstractions:定义微软XXXX的必须的抽象
  • Microsoft.Framework.XXXX:定义微软的XXXX的基础实现,内部类多实现Microsoft.Framework.XXXX.Abstractions中接口

配置文件中,肯定少不了配置文件类的基础接口定义:IConfiguration;我们知道新的配置文件实现,支持配置文件有多个来源,可以来自

这个工程代码比较少,下面我就将接口定义罗列如下:

[Asp.net 5] Configuration[Asp.net 5] Configuration
public interface IConfigurationSource  {    bool TryGet(string key, out string value);    void Set(string key, string value);    void Load();    IEnumerable<string> ProduceConfigurationSections(      IEnumerable<string> earlierKeys,      string prefix,      string delimiter);  } public interface IConfigurationBuilder  {    string BasePath { get; }    IEnumerable<IConfigurationSource> Sources { get; }    IConfigurationBuilder Add(IConfigurationSource configurationSource);    IConfiguration Build();  }public interface IConfiguration  {    string this[string key] { get; set; }    string Get(string key);    bool TryGet(string key, out string value);    IConfiguration GetConfigurationSection(string key);    IEnumerable<KeyValuePair<string, IConfiguration>> GetConfigurationSections();    IEnumerable<KeyValuePair<string, IConfiguration>> GetConfigurationSections(string key);    void Set(string key, string value);    void Reload();  }

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:[Asp.net 5] Configuration

关键词:ASP.NET

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。