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的更多相关文章

  1. 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 ...

  2. Apache2.4:AH01630 client denied by server configuration

    问题说明:Apache服务总共有4个,是为了防止单点故障和负载均衡,负载均衡控制由局方的F5提供. 访问的内容在NAS存储上,现象是直接访问每个apache的服务内容都是没有问题,但是从负载地址过来的 ...

  3. Fedora 22中的Locale and Keyboard Configuration

    Introduction The system locale specifies the language settings of system services and user interface ...

  4. ABP源码分析四:Configuration

    核心模块的配置 Configuration是ABP中设计比较巧妙的地方.其通过AbpStartupConfiguration,Castle的依赖注入,Dictionary对象和扩展方法很巧妙的实现了配 ...

  5. External Configuration Store Pattern 外部配置存储模式

    Move configuration information out of the application deployment package to a centralized location. ...

  6. SCVMM中Clone虚拟机失败显示Unsupported Cluster Configuration状态

    在SCVMM进行虚拟机的Clone,虽然失败了,但是Clone出虚拟机却显示在SCVMM控制台的虚拟机的列表中,并且状态是Unsupported Cluster Configuration.无法修复, ...

  7. commons configuration管理项目的配置文件

    Commons Confifutation commons configuration可以很方便的访问配置文件和xml文件中的的内容.Commons Configuration 是为了提供对属性文件. ...

  8. Elasticsearch Configuration 中文版

    ##################### Elasticsearch Configuration Example ##################### # This file contains ...

  9. Spark 官方文档(4)——Configuration配置

    Spark可以通过三种方式配置系统: 通过SparkConf对象, 或者Java系统属性配置Spark的应用参数 通过每个节点上的conf/spark-env.sh脚本为每台机器配置环境变量 通过lo ...

  10. spring configuration 注解

    org.springframework.context.annotation @annotation.Target({ElementType.TYPE}) @annotation.Retention( ...

随机推荐

  1. JS中数据结构之链表

    1.链表的基本介绍 数组不总是组织数据的最佳数据结构,在很多编程语言中,数组的长度是固定的,所以当数组已被数据填满时,再要加入新的元素就会非常困难.在数组中,添加和删除元素也很麻烦,因为需要将数组中的 ...

  2. Sublime 配置代理以及 Socks5 转 http 代理

    一.原因 在使用 sublime 3.2.1 的时候,安装插件时出错 因为被墙的原因,所以要设置代理 设置路径: 首选项 -> Package -> Settings -> Pack ...

  3. Invalid bound statement (not found)错误

    都对着,为什么会报这个错呢,mapper也拿到了,为什么查询时出错呢,最后看target里编译的文件发现少了mapping,xml没编译过去. 我的目录结构:dao层都编译过去了,但mapper.xm ...

  4. Centos7.4 配置之MySQL 8.0【转】

    首先查看Mysql最新版本, 此时,目前最新版本为8.0. 开始安装前需要一些准备工作. 1,将本地的MariaDB或者已经安装的MySQL其他版本卸载. (一)卸载本地的本地的MariaDB: 由于 ...

  5. 使用Echarts中遇到值得记录的小案例(一)

    需求部分 在开发项目的时候遇到一个需求,就是如何保证echarts图表里至少显示一个图例的数据(也就是最后一个图例不能变成unselected的状态)下图是最初加载时的画面 不想出现图例都被点击取消导 ...

  6. 【SpringBoot】 一种解决接口返回慢的方式

    前言 使用springboot开发后台代码的时候,很核心的一个功能是为前端提供接口,那么很可能你会遇到如下问题: 1. 接口里面调用的service层是第三方库或者第三方后台程序,导致访问很慢. 2. ...

  7. 服务端:WCF服务层安全检查核心类

    using System.Data; using CSFrameworkV4_5.Common; using CSFrameworkV4_5.Core.SystemSecurity; using CS ...

  8. 爱奇艺面试Python,竟然挂在第5轮…(转)

    今天给大家分享我曾经在爱奇艺的面试,过程还是比较有意思的,可以给大家一些参考 聊骚阶段 嗲妹妹:你好,我是爱奇艺的HR,我们正在招聘运维开发岗位,请问您最近有在看工作机会吗? 我:(这声音也太酥了吧我 ...

  9. webpack请求文件路径代理

    在开发模式下,访问页面请求会跑到根路径,因为写的都  ./images  而index又在根目录, 所以访问地址会是 http://localhost:8080/images/abc.jpg  而实际 ...

  10. 有根树的表达 Aizu - ALDS1_7_A: Rooted Trees

    有根树的表达 题目:Rooted Trees Aizu - ALDS1_7_A  A graph G = (V, E) is a data structure where V is a finite ...