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( ...
随机推荐
- vagrant up ----失败 问题解决
命令行启动提示信息 there was an error while executing `vboxmanage`, a cli used by vagrant for controlling vir ...
- hdu 5964:平行四边形 【计算几何】
打重现赛时,一点思路也没有,然后又看到这题AC数那么少,就直接放弃了.今天重新看了看,借鉴了下别人的,发现此题应该算是一道可解题. 看上去,这题的ans是同时有两个点作为自变量的函数(然而n^2复杂度 ...
- 【leetcode】668. Kth Smallest Number in Multiplication Table
题目如下: 解题思路:几乎和[leetcode]719. Find K-th Smallest Pair Distance 的方法一样.只不过一个是减法一个是乘法,还有一点区别是[leetcode]7 ...
- 【leetcode】433. Minimum Genetic Mutation
题目如下: 解题思路:我的思路很简单,就是利用BFS方法搜索,找到最小值. 代码如下: class Solution(object): def canMutation(self, w, d, c, q ...
- Java线程通信-生产者消费者问题
线程通信示例——生产者消费者问题 这类问题描述了一种情况,假设仓库中只能存放一件产品,生产者将生产出来的产品放入仓库,消费者将仓库中的产品取走消费.假设仓库中没有产品,则生产者可以将 产品放入仓库,有 ...
- spring-cloud:eureka server单机、双机、集群示例
1.运行环境 开发工具:intellij idea JDK版本:1.8 项目管理工具:Maven 4.0.0 2.GITHUB地址 https://github.com/nbfujx/springCl ...
- JS中常见的几种报错类型
1.SyntaxError(语法错误) 解析代码时发生的语法错误 var 1a; //Uncaught SyntaxError: Invalid or unexpected token 变量名错误 c ...
- BZOJ 2982: combination Lucas模板题
Code: #include<bits/stdc++.h> #define ll long long #define maxn 1000003 using namespace std; c ...
- Outlets
Outlets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- 前端每日实战:18# 视频演示如何用纯 CSS 创作 404 文字变形为 NON 文字的交互特效
效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/ZoxjXm 可交互视频教程 此视频 ...