神秘爹地妈咪爱出逃,郝明莉近况,成都摄影论坛
webconfig:
[html]
<?xml version="1.0"?>
<!--
有关如何配置 asp.net 应用程序的详细信息,
-->
<configuration>
<configsections>
<section name="remotingobject" type="remotingobject"/>
</configsections>
<system.web>
<compilation debug="true" targetframework="4.0"/>
</system.web>
<remotingobject available="true" polltimeout="00:01:00" location="tcp://ordercomputer:8010/orderservice"/>
</configuration>
获取自定义节点 内容:
[csharp]
//打开配置文件
configuration config = webconfigurationmanager.openwebconfiguration("~/");
//获取配置节对象
remotingobject custsection =
(remotingobject)config.getsection("remotingobject");
//显示配置节信息
lblinfo.text += "获取自定义配置节的信息...<br />" +
"<b>位置:</b> " + custsection.location +
"<br /><b>是否可用:</b> " + custsection.available.tostring() +
"<br /><b>超时时间:</b> " + custsection.polltimeout.tostring() + "<br /><br />";
remotingobject对象类
[csharp]
using system;
using system.collections.generic;
using system.linq;
using system.web;
using system.configuration;
/// <summary>
///remotingobject 的摘要说明
/// </summary>
public class remotingobject : configurationsection
{
//定义远程对象是否可用
[configurationproperty("available", isrequired = false, defaultvalue = true)]
public bool available
{
get { return (bool)base["available"]; }
set { base["available"] = value; }
}
//定义远程对象的超时时间
[configurationproperty("polltimeout", isrequired = true)]
public timespan polltimeout
{
get { return (timespan)base["polltimeout"]; }
set { base["polltimeout"] = value; }
}
//定义远程对象所在的位置
[configurationproperty("location", isrequired = true)]
public string location
{
get { return (string)base["location"]; }
set { base["location"] = value; }
}
}
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论