1.Configuration
1.Configuration(public sealed class Configuration)
定义:表示适用于特定计算机、应用程序或资源的配置文件。 此类不能被继承
获取实例:
ConfigurationManager 类,如果你的实体是客户端应用程序
ConfigurationManager 类,如果你的实体是客户端应用程序。
继承:
Object --> Configuration
属性:
AppSettings | 获取应用于此 Configuration 对象的 AppSettingsSection 对象配置节 |
AssemblyStringTransformer | 指定一个函数委托,用于转换配置文件中的程序集字符串 |
ConnectionStrings | 获取应用于此 Configuration 对象的 ConnectionStringsSection 配置节对象 |
EvaluationContext | 获取 Configuration 对象的 ContextInformation 对象。 |
FilePath | 获取由 Configuration 对象表示的配置文件的物理路径。 |
HasFile | 获取一个值,该值指示由此 Configuration 对象表示的资源是否存在相应的文件。 |
Locations | 获取此 Configuration 对象内定义的位置。 |
NamespaceDeclared | 获取或设置一个值,该值指示配置文件是否具有 XML 命名空间。 |
RootSectionGroup | 获取此 Configuration 对象的根 ConfigurationSectionGroup。 |
SectionGroups | 获取由此配置定义的节组的集合。 |
Sections | 获取此 Configuration 对象定义的节的集合。 |
TargetFramework | 在将当前版本之前的某个版本作为目标时,指定 .NET Framework 的目标版本。 |
TypeStringTransformer | 指定一个函数委托,用于转换配置文件中的类型字符串。 |
方法:
GetSection(string sectionName) | 返回指定的 ConfigurationSection 对象 |
GetSectionGroup (string path) |
获取指定的 ConfigurationSectionGroup 对象。 |
Save () |
将包含在此 Configuration 对象中的配置设置写入当前 XML 配置文件 |
Save (System.Configuration.ConfigurationSaveMode mode) |
将包含在此 Configuration 对象中的配置设置写入当前 XML 配置文件 |
Save (System.Configuration.ConfigurationSaveMode mode, bool forceUpdateAll) |
将包含在此 Configuration 对象中的配置设置写入当前 XML 配置文件 |
SaveAs (string filename) |
将包含在此 Configuration 对象中的配置设置写入指定的 XML 配置文件 |
SaveAs (string filename, System.Configuration.ConfigurationSaveMode mode) |
将包含在此 Configuration 对象中的配置设置写入指定的 XML 配置文件 |
SaveAs (string filename, System.Configuration.ConfigurationSaveMode mode, bool forceUpdateAll) |
将包含在此 Configuration 对象中的配置设置写入指定的 XML 配置文件 |
2.实际应用
配置文件如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="appsetting1" value="appsetting1" />
</appSettings>
</configuration>
1)获取appSettings节点中的值
string value = ConfigurationManager.AppSettings["appsetting1"];
Console.WriteLine(value);
//返回:appsetting1
1.Configuration的更多相关文章
- PhpStorm和WAMP配置调试参数,问题描述Error. Interpreter is not specified or invalid. Press “Fix” to edit your project configuration.
PhpStorm和WAMP配置调试参数 问题描述: Error. Interpreter is not specified or invalid. Press “Fix” to edit your p ...
- Apache2.4:AH01630 client denied by server configuration
问题说明:Apache服务总共有4个,是为了防止单点故障和负载均衡,负载均衡控制由局方的F5提供. 访问的内容在NAS存储上,现象是直接访问每个apache的服务内容都是没有问题,但是从负载地址过来的 ...
- Fedora 22中的Locale and Keyboard Configuration
Introduction The system locale specifies the language settings of system services and user interface ...
- ABP源码分析四:Configuration
核心模块的配置 Configuration是ABP中设计比较巧妙的地方.其通过AbpStartupConfiguration,Castle的依赖注入,Dictionary对象和扩展方法很巧妙的实现了配 ...
- External Configuration Store Pattern 外部配置存储模式
Move configuration information out of the application deployment package to a centralized location. ...
- SCVMM中Clone虚拟机失败显示Unsupported Cluster Configuration状态
在SCVMM进行虚拟机的Clone,虽然失败了,但是Clone出虚拟机却显示在SCVMM控制台的虚拟机的列表中,并且状态是Unsupported Cluster Configuration.无法修复, ...
- commons configuration管理项目的配置文件
Commons Confifutation commons configuration可以很方便的访问配置文件和xml文件中的的内容.Commons Configuration 是为了提供对属性文件. ...
- Elasticsearch Configuration 中文版
##################### Elasticsearch Configuration Example ##################### # This file contains ...
- Spark 官方文档(4)——Configuration配置
Spark可以通过三种方式配置系统: 通过SparkConf对象, 或者Java系统属性配置Spark的应用参数 通过每个节点上的conf/spark-env.sh脚本为每台机器配置环境变量 通过lo ...
- spring configuration 注解
org.springframework.context.annotation @annotation.Target({ElementType.TYPE}) @annotation.Retention( ...
随机推荐
- C#-弄懂泛型和协变、逆变
脑图概览 泛型声明和使用 协变和逆变 <C#权威指南>上在委托篇中这样定义: 协变:委托方法的返回值类型直接或者间接地继承自委托前面的返回值类型; 逆变:委托签名中的参数类型继承自委托方法 ...
- QT中视图(setViewport)和窗口(setWindow) 小总结
参考博客: https://blog.csdn.net/weixin_39583140/article/details/92798127 https://blog.csdn.net/u01244271 ...
- Delphi Treeview 用法(概念、属性、添加编辑插入节点、定位节点、拖拽等)
今天再细研究了一下Treeview的用法,网上虽然总结了很多,但是还是有很多节点没有讲到了,也给使用中遇到很多问题.特地总结一下: 1.概念 Treeview用于显示按照树形结构进行组织的数据.Tre ...
- mysql 一条sql完成saveOrUpdate 存在即更新
关键字 on duplicate key update <pre name="code" class="sql"> insert into tabl ...
- git filter-branch
https://github.com/git-for-windows/git/issues/2206 https://git-scm.com/docs/git-filter-branch The -- ...
- IIS的站点配置存储在applicationHost.config
C:\Windows\System32\inetsrv\Config\applicationHost.config
- 信息安全-攻击-XSS:XSS/CSS 攻击
ylbtech-信息安全-攻击-XSS:XSS/CSS 攻击 XSS攻击通常指的是通过利用网页开发时留下的漏洞,通过巧妙的方法注入恶意指令代码到网页,使用户加载并执行攻击者恶意制造的网页程序.这些恶意 ...
- Git 提交的正确姿势
Git 提交的正确姿势:Commit message 编写指南 SCOP范围 middleware core config plugin test type范围 Git 每次提交代码,都要写 Comm ...
- Python 进阶_函数式编程
目录 目录 函数式编程 Python 函数式编程的特点 高阶函数 匿名函数 lambda 函数式编程相关的内置函数 filter 序列对象过滤器 map reduce 折叠 自定义的排序函数 最后 函 ...
- GET和POST区别及缓存问题
2.就是get和post区别的缓存问题. 首先要了解什么是缓存. HTTP缓存的基本目的就是使应用执行的更快,更易扩展,但是HTTP缓存通常只适用于idempotent request(可以理解为查询 ...