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. (IDEA) 设置编码统一为UTF-8

    File->Settings->Editor->File Encodings

  2. 死磕 java线程系列之终篇

    (手机横屏看源码更方便) 简介 线程系列我们基本就学完了,这一个系列我们基本都是围绕着线程池在讲,其实关于线程还有很多东西可以讲,后面有机会我们再补充进来.当然,如果你有什么好的想法,也可以公从号右下 ...

  3. 简单搭建DNS服务器——bind

    1安装bind yum install -y bind bind-utils bind-chroot 2 修改配置文件 # grep '^[^#]' /etc/named.conf options { ...

  4. RouterOS安装以及搭建DHCP PPPoE PPTP L2TP服务

    1.安装routeros https://mikrotik.com/download 网站下载routeros镜像 vdi格式 :VirtualBox默认创建的硬盘文件格式 vmdk格式:VMware ...

  5. [笔记]IDEA使用笔记

    1.IDEA的目录结构 2.所有的源文件都必须写在src文件夹下, 3.输入psvm再按回车,就会生成主函数: 4.输入sout就会生成输出语句的格式: 5.ALT+4   调出上次运行的结果出来看看 ...

  6. pat 1058 A+B in Hogwarts(20 分)

    1058 A+B in Hogwarts(20 分) If you are a fan of Harry Potter, you would know the world of magic has i ...

  7. nyoj 92-图像有用区域 (BFS)

    92-图像有用区域 内存限制:64MB 时间限制:3000ms 特判: No 通过数:4 提交数:12 难度:4 题目描述: “ACKing”同学以前做一个图像处理的项目时,遇到了一个问题,他需要摘取 ...

  8. nyoj 276-比较字母大小 (顺序比较, 逆序输出)

    276-比较字母大小 内存限制:64MB 时间限制:3000ms 特判: No 通过数:13 提交数:15 难度:1 题目描述: 任意给出两个英文字母,比较它们的大小,规定26个英文字母A,B,C.. ...

  9. Docker+Dubbo+Zookeeper实现RPC远程调用

    Docker+Dubbo+Zookeeper 1.安装Docker 1.1卸载旧版本的Docker //如果Docker处于与运行状态 未运行可跳过 [root@MrADiao ~]# systemc ...

  10. 自制window下core animation引擎 - demo第二弹 - 仿QQ电脑管家加速小火箭

    一年前想写一个像cocoa那样,可以方便层动画开发的引擎,写着写着又逆向它的QuartzCore.framework,也就是CoreAnimation的底层,已经大半年没有搞windows这个引擎.大 ...