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 详解的更多相关文章

  1. AssemblyInfo.cs 详解

    前言 ? .net工程(包括Web和WinForm)的Properties文件夹下自动生成一个名为AssemblyInfo.cs的文件,一般情况下我们很少直接改动该文件.但我们实际上通过另一个形式操作 ...

  2. .Net魔法堂:AssemblyInfo.cs文件详解

    一.前言 .net工程的Properties文件夹下自动生成一个名为AssemblyInfo.cs的文件,一般情况下我们很少直接改动该文件.但我们实际上通过另一个形式操作该文件.那就是通过在鼠标右键点 ...

  3. AssemblyInfo.cs文件详解

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq395537505/article/details/49661555 一.前言 .net工程的Pr ...

  4. Kooboo CMS - Html.FrontHtml[Helper.cs] 各个方法详解

    下面罗列了方法详解,每一个方法一篇文章. Kooboo CMS - @Html.FrontHtml().HtmlTitle() 详解 Kooboo CMS - Html.FrontHtml.Posit ...

  5. JS函数动作分层结构详解及Document.getElementById 释义 js及cs数据类型区别 事件 函数 变量 script标签 var function

    html +css 静态页面 js     动态 交互   原理: js就是修改样式, 比如弹出一个对话框. 弹出的过程就是这个框由disable 变成display:enable. 又或者当鼠标指向 ...

  6. Linq之旅:Linq入门详解(Linq to Objects)

    示例代码下载:Linq之旅:Linq入门详解(Linq to Objects) 本博文详细介绍 .NET 3.5 中引入的重要功能:Language Integrated Query(LINQ,语言集 ...

  7. Xamarin.Android通知详解

    一.发送通知的机制 在日常的app应用中经常需要使用通知,因为服务.广播后台活动如果有事件需要通知用户,则需要通过通知栏显示,而在Xamarin.Android下的通知需要获取Notification ...

  8. CentOS 6.3下Samba服务器的安装与配置方法(图文详解)

    这篇文章主要介绍了CentOS 6.3下Samba服务器的安装与配置方法(图文详解),需要的朋友可以参考下   一.简介  Samba是一个能让Linux系统应用Microsoft网络通讯协议的软件, ...

  9. 基础拾遗------webservice详解

    基础拾遗 基础拾遗------特性详解 基础拾遗------webservice详解 基础拾遗------redis详解 基础拾遗------反射详解 基础拾遗------委托详解 基础拾遗----- ...

随机推荐

  1. [springboot 开发单体web shop] 2. Mybatis Generator 生成common mapper

    Mybatis Generator tool 在我们开启一个新项目的研发后,通常要编写很多的entity/pojo/dto/mapper/dao..., 大多研发兄弟们都会抱怨,为什么我要重复写CRU ...

  2. 为啥不能#define private public了?

    今天在写一个单元测试的时候出现了如下编译错误: 以前用gtest为了测试业务代码里的private函数和变量,一直是在单元测试代码通过#define private public这样的trick达到测 ...

  3. python pytesseract使用

    正确使用方法 1.tesseract-orc安装 tesseract-ocr-setup-3.05.00dev.exe下载 2.pytesseract pip install pytesseract ...

  4. 学习笔记03http协议

    1.浏览器就是一个sokect客户端,使用http协议与服务器进行交流.http请求:请求头:(请求方法)sp(url)sp http/1.x <cr><lf>(通用头类型名) ...

  5. [考试反思]NOIP模拟测试19:洗礼

    []260 []230[]210 []200[8]170[9]160 这套题一般,数据很弱,T1T2暴力都能A,而且都是一些思维题,想不到就爆0. 原因不明,很多一直很强的人在这一次滑铁卢了,于是我个 ...

  6. NOIP模拟 25

    分层考试第一场. 垫底. T1 lighthouse 观察到m很小,想到容斥. 正常人都想枚举子集,只有我打了搜索. 为了压行,我压缩了几句分类讨论. 压错了,原地爆炸 考场思路: 不容斥这也不可做啊 ...

  7. Nginx正则配置

    Nginx配置中Location的语法规则 location [ = | ~ | ~* | ^~ | !~ | !~* ] /uri/{ - } = 表示精确匹配 ~ 表示区分大小写正则匹配 ~* 表 ...

  8. sqlite修改表、表字段等与sql server的不同之处

    sqlite中只支持 ALTER TABLE 命令的 RENAME TABLE 和 ADD COLUMN. 其他类型的 ALTER TABLE 操作如 DROP COLUMN,ALTER COLUMN ...

  9. 《计算机网络 自顶向下方法》 第2章 应用层 Part2

    域名.主机名?   从范围上看: 域名的范围比主机名大 一个域名下通常有多个主机名 从组成上看: 主机名 = 服务器名(或计算机名) + 域名 举例说明: baidu.com 是百度的域名 www.b ...

  10. 【持续更新】【pat】pat刷题技巧记录

    修改code completion快捷键位CTRL+ENTER,帮助提示函数名称 修改命令行提示符的属性,开启快速编辑模式,方便调试 添加c++11语言标准支持 开启代码调试功能 对输入的字符串进行切 ...