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. 10.Servlet简单介绍

    1.什么是Servlet * Servlet是javaweb的三大组件之一,它属于动态资源.Servlet的作用是处理请求,服务器会把接收到的请求交给Servlet来处理,在Servlet种通常需要: ...

  2. 【leetcode】1021. Remove Outermost Parentheses

    题目如下: A valid parentheses string is either empty (""), "(" + A + ")", ...

  3. [转]Windows 10 无法访问共享的解决办法大全

    本文前面介绍 Windows 10 操作系统无法访问其他电脑的共享文件夹,而其他电脑访问该共享可以访问的解决办法. 简单点说就是,你的操作系统是 Win10 ,你访问不了某台电脑的共享,但是别人可以. ...

  4. shell脚本学习(6)awk 编排字段

    awk能取出文本字段重新编排 1 awk的用法 awk ‘program’ [file] 2 其中program 可以写成 ‘parrtern {action}’    pattern 或 actio ...

  5. JSP中获取客户端或浏览端信息的方式

    request应用:在JSP页面显示访问者IP  方式一:纯前台,不涉及后台操作.直接在jsp页面中需要显示IP的地方使用 代码:<%=request.getRemoteAddr()%> ...

  6. AT2000 Leftmost Ball(计数dp+组合数学)

    传送门 解题思路 设\(f[i][j]\)表示填了\(i\)个白色,\(j\)种彩色的方案数,那么显然\(j<=i\).考虑这个的转移,首先可以填一个白色,就是\(f[i][j]=f[i-1][ ...

  7. CodeForces - 1038D (线性DP)

    题目:https://codeforces.com/problemset/problem/1038/D 题意:给你n个数字,每个数字可以吃左右两边的数,然后吃完后自己变成 a[i]-a[i+1]或者a ...

  8. Key Set

    http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1011&cid=594 Key Set Time Limit: 2000 ...

  9. asd的甩锅计划

    asd的甩锅计划 时间限制: 1 Sec  内存限制: 128 MB提交: 177  解决: 19[提交][状态] 题目描述 大家对hdu上面的畅通工程系列一定很熟悉了吧.比如如下一段,就是畅通工程里 ...

  10. python实现计时器(装饰器)

    1.写一个装饰器,查看函数执行的时间 import time # 装饰器run_time,@run_time加在谁头上,谁就是参数fundef run_time(fun): start_time = ...