supersocket/SocketEngin/BootstrapFactory.cs 详解
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperSocket.SocketBase;
using SuperSocket.SocketEngine.Configuration;
using SuperSocket.SocketBase.Config;
using System.Configuration; namespace SuperSocket.SocketEngine
{
/// <summary>
/// Bootstrap Factory
/// </summary>
public static class BootstrapFactory
{
/// <summary>
/// Creates the bootstrap.
/// </summary>
/// <param name="config">The config.</param>
/// <returns></returns>
public static IBootstrap CreateBootstrap(IConfigurationSource config)
{
if (config == null)
throw new ArgumentNullException("config"); if (config.Isolation == IsolationMode.AppDomain)
return new AppDomainBootstrap(config);
else if (config.Isolation == IsolationMode.Process)
return new ProcessBootstrap(config);
else
return new DefaultBootstrap(config);
} /// <summary>
/// Creates the bootstrap from app configuration's socketServer section.
/// </summary>
/// <returns></returns>
public static IBootstrap CreateBootstrap()
{
var configSection = ConfigurationManager.GetSection("superSocket"); if (configSection == null)//to keep compatible with old version
configSection = ConfigurationManager.GetSection("socketServer"); if(configSection == null)
throw new ConfigurationErrorsException("Missing 'superSocket' or 'socketServer' configuration section."); var configSource = configSection as IConfigurationSource;
if(configSource == null)
throw new ConfigurationErrorsException("Invalid 'superSocket' or 'socketServer' configuration section."); return CreateBootstrap(configSource);
} /// <summary>
/// Creates the bootstrap.
/// </summary>
/// <param name="configSectionName">Name of the config section.</param>
/// <returns></returns>
public static IBootstrap CreateBootstrap(string configSectionName)
{
var configSource = ConfigurationManager.GetSection(configSectionName) as IConfigurationSource; if (configSource == null)
throw new ArgumentException("Invalid section name."); return CreateBootstrap(configSource);
} /// <summary>
/// Creates the bootstrap from configuration file.
/// </summary>
/// <param name="configFile">The configuration file.</param>
/// <returns></returns>
public static IBootstrap CreateBootstrapFromConfigFile(string configFile)
{
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = configFile; var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); var configSection = config.GetSection("superSocket"); if (configSection == null)
configSection = config.GetSection("socketServer"); return CreateBootstrap(configSection as IConfigurationSource);
}
}
}
supersocket/SocketEngin/BootstrapFactory.cs 详解的更多相关文章
- AssemblyInfo.cs 详解
前言 ? .net工程(包括Web和WinForm)的Properties文件夹下自动生成一个名为AssemblyInfo.cs的文件,一般情况下我们很少直接改动该文件.但我们实际上通过另一个形式操作 ...
- .Net魔法堂:AssemblyInfo.cs文件详解
一.前言 .net工程的Properties文件夹下自动生成一个名为AssemblyInfo.cs的文件,一般情况下我们很少直接改动该文件.但我们实际上通过另一个形式操作该文件.那就是通过在鼠标右键点 ...
- AssemblyInfo.cs文件详解
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq395537505/article/details/49661555 一.前言 .net工程的Pr ...
- Kooboo CMS - Html.FrontHtml[Helper.cs] 各个方法详解
下面罗列了方法详解,每一个方法一篇文章. Kooboo CMS - @Html.FrontHtml().HtmlTitle() 详解 Kooboo CMS - Html.FrontHtml.Posit ...
- JS函数动作分层结构详解及Document.getElementById 释义 js及cs数据类型区别 事件 函数 变量 script标签 var function
html +css 静态页面 js 动态 交互 原理: js就是修改样式, 比如弹出一个对话框. 弹出的过程就是这个框由disable 变成display:enable. 又或者当鼠标指向 ...
- Linq之旅:Linq入门详解(Linq to Objects)
示例代码下载:Linq之旅:Linq入门详解(Linq to Objects) 本博文详细介绍 .NET 3.5 中引入的重要功能:Language Integrated Query(LINQ,语言集 ...
- Xamarin.Android通知详解
一.发送通知的机制 在日常的app应用中经常需要使用通知,因为服务.广播后台活动如果有事件需要通知用户,则需要通过通知栏显示,而在Xamarin.Android下的通知需要获取Notification ...
- CentOS 6.3下Samba服务器的安装与配置方法(图文详解)
这篇文章主要介绍了CentOS 6.3下Samba服务器的安装与配置方法(图文详解),需要的朋友可以参考下 一.简介 Samba是一个能让Linux系统应用Microsoft网络通讯协议的软件, ...
- 基础拾遗------webservice详解
基础拾遗 基础拾遗------特性详解 基础拾遗------webservice详解 基础拾遗------redis详解 基础拾遗------反射详解 基础拾遗------委托详解 基础拾遗----- ...
随机推荐
- InfluxDB常见疑问与解答 - 数据写入时如何在表级别指定保留策略
网友Siguoei:我想让一个库中不同的measurment能够指定不同的保存策略.而不是写入时使用数据库的默认保留策略. Answer:这个特性InfluxDB支持的,写入时序数据时,在行协议前加上 ...
- CSPS_106
这场 死的太惨了! 我也不把我的错误像倒垃圾一样放在blog里了qwq 通过这场考试 我深深地认识到了情绪对人类的影响qwq 只要这种东西,不要出现在我的csp中就好了 T1 区间DP.. T2 枚举 ...
- NOIP模拟测试19考试反思
这次考试是存在很大问题的,(如果不是T1T2出乎意料地A了,鬼知道会发生什么) T2A是情理之中,考试的时候测的极限数据跑的很快(无论m什么范围),但是T1真的...... T3没有分配太多的时间+没 ...
- 洛谷 P 5 3 0 4 [GXOI/GZOI2019]旅行者
题目描述 J 国有 n 座城市,这些城市之间通过 m 条单向道路相连,已知每条道路的长度. 一次,居住在 J 国的 Rainbow 邀请 Vani 来作客.不过,作为一名资深的旅行者,Vani 只对 ...
- Java自动化测试框架-12 - TestNG之xml文件详解篇 (详细教程)
1.简介 现在这篇,我们来学习TestNG.xml文件,前面我们已经知道,TestNG就是运行这个文件来执行测试用例的.通过本篇,你可以进一步了解到:这个文件是配置测试用例,测试套件.简单来说,利用这 ...
- 猫眼电影App抓包获取评论数据接口
之前在CSDN程序人生公众号上看到了这篇文章<邪不压正>评分持续走低,上万条网友评论揭秘,是救救姜文还是救救观众?,文中提到了通过抓包猫眼App发现了评论的数据接口:http://m.m ...
- 使用Bootstrap制作简单的旅游主页
页面效果 代码: 需要导入bootstrapt文件,解压至项目中. 下载地址:https://v3.bootcss.com/getting-started/#download <!DOCTYPE ...
- avtivmq(订阅写法)
发布-订阅消息模式与点对点模式类似,只不过在session创建消息队列时,由session.createQuene()变为session.createTopic(). 消息发布者代码: 消息订阅者代码 ...
- Ubuntu18.04.3 LTS初体验
安装系统 想来虚拟机安装太慢,正好有一台旧电脑,干脆整个乌班图系统. 启动盘工具:UltraISO,老牌工具了. 上官网下载ISO镜像文件: https://cn.ubuntu.com/downloa ...
- ASP.NET Core 1.0: Using Entity Framework Core
伴随着ASP.NET Core 1.0发布的还有Entity Framework Core 1.0; 官方文档链接:https://docs.efproject.net/en/latest/platf ...