<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--<otherconfig configSource="XmlConfig\other.config" />-->
<otherconfig a="" b="" c=""/>
</configuration>
public class OtherConfigInfo : ConfigurationSection
{
/// <summary>
/// 获取配置信息
/// </summary>
/// <returns></returns>
public static OtherConfigInfo GetConfig()
{
return GetConfig("otherconfig");
}
/// <summary>
/// 获取配置信息
/// </summary>
/// <param name="sectionName">xml节点名称</param>
/// <returns></returns>
public static OtherConfigInfo GetConfig(string sectionName)
{
OtherConfigInfo section = (OtherConfigInfo)ConfigurationManager.GetSection(sectionName);
if (section == null)
throw new ConfigurationErrorsException("Section " + sectionName + " is not found.");
return section;
} [ConfigurationProperty("a", IsRequired = false)]
public string a
{
get
{
return (string)base["a"];
}
set
{
base["a"] = value;
}
} [ConfigurationProperty("b", IsRequired = false)]
public string b
{
get
{
return (string)base["b"];
}
set
{
base["b"] = value;
}
} [ConfigurationProperty("c", IsRequired = false)]
public string c
{
get
{
return (string)base["c"];
}
set
{
base["c"] = value;
}
}
}

  

 //调用方法
OtherConfigInfo configInfo = OtherConfigInfo.GetConfig();
Console.WriteLine(configInfo.a);

App.config自定义节点读取的更多相关文章

  1. 一个web.Config或app.Config自定义段configSections的示例

    一个web.Config或app.Config自定义段configSections的示例 越来越觉得,直接用配置文件app.Config或web.Config配置应用系统的运行参数,比自己做一个xml ...

  2. 如何使用App.config文件,读取字符串?

    如何使用App.config文件,读取字符串? .在项目里添加App.config文件,内容如下: <?xml version="1.0" encoding="ut ...

  3. 读取App.config自定义标签的值

    一:程序截图 二:具体代码 config配置: <?xml version="1.0" encoding="utf-8" ?> <config ...

  4. App.Config自定义配置节点

    配置文件: <?xml version="1.0" encoding="utf-8"?> <configuration> <con ...

  5. Web.config自定义节点configSections

    1.为什么需要自定义节点 为了增加应用程序的可移植性,通常网站需要配置一些自定义的节点,例如:文件上传的路径等,再深入的应用,可以定义工厂方法需要创建的类. 2.configSections使用方法 ...

  6. 一个web.Config或app.Config自定义段configSections的示例--转

    直接用配置文件app.Config或web.Config配置应用系统的运行参数,比自己做一个xml配置文件,简洁方便得多.这两个配置文件不仅有常见的connectionStrings和appSetti ...

  7. C# App.config 自定义 配置节 出现的问题:配置系统未能初始化

    C# 读取app.config配置文件 节点键值,提示 "配置系统未能初始化" 错误的解决方案 新建C#项目,在app.config中添加了appSettings项,运行时出现&q ...

  8. C# App.config 自定义 配置节

    1)App.config <?xml version="1.0" encoding="utf-8" ?><configuration>  ...

  9. C# App.config 自定义 配置节 报错“配置系统未能初始化” 解决方法

    App.config,结果运行的时候出现了 "配置系统未能初始化" 的错误.找了半天才发现是下面的原因造成的: "如果配置文件中包含configSections元素,则c ...

随机推荐

  1. java的Integer与int的比较

  2. XML错误信息Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-4.0.xsd). For more information, right click on the message in the Problems View ...

    错误信息:Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-4.0.x ...

  3. 浅谈URL跳转与Webview安全

    学习信息安全技术的过程中,用开阔的眼光看待安全问题会得到不同的结论. 在一次测试中我用Burpsuite搜索了关键词url找到了某处url,测试一下发现waf拦截了指向外域的请求,于是开始尝试绕过.第 ...

  4. Vue之生命周期函数和钩子函数详解

    在学习vue几天后,感觉现在还停留在初级阶段,虽然知道怎么和后端做数据交互,但是对对vue的生命周期不甚了解.只知道简单的使用,而不知道为什么,这对后面的踩坑是相当不利的.因为我们有时候会在几个钩子函 ...

  5. (翻译)W3C的Turtle文档

    主要翻译如下页面,https://www.w3.org/TR/turtle/,对该页面中Turtle的内容部分进行翻译,希望对使用Turtle的朋友们有所帮助. 1 简介 2 Turtle语言 2.1 ...

  6. SpringBoot SpEL表达式注入漏洞-分析与复现

    目录 0x00前言 0x01触发原因 0x02调试分析 0x03补丁分析 0x04参考文章 影响版本: 1.1.0-1.1.12 1.2.0-1.2.7 1.3.0 修复方案:升至1.3.1或以上版本 ...

  7. SpringBoot进阶教程(二十六)整合Redis之共享Session

    集群现在越来越常见,当我们项目搭建了集群,就会产生session共享问题.因为session是保存在服务器上面的.那么解决这一问题,大致有三个方案,1.通过nginx的负载均衡其中一种ip绑定来实现( ...

  8. 《k8s-1.13版本源码分析》- Scheduler启动前逻辑

    本文原始地址(gitbook格式):https://farmer-hutao.github.io/k8s-source-code-analysis/core/scheduler/before-sche ...

  9. com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的区别

    com.mysql.jdbc.Driver 是 mysql-connector-java 5中的,com.mysql.cj.jdbc.Driver 是 mysql-connector-java 6中的 ...

  10. 简单地做一下“回到顶部”按钮,用jQuery实现其隐藏和显示

    1.首先,我们要准备HTML代码: <div id="return-top"> <a href="#top">返回顶部</a> ...