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. 使用Java调用exe可执行文件

    一.出发点 平日里,我们看到了很多已经成型的可执行文件,而且经过了一定的封装.因为开源的关系,大多时候可以自己使用eclipse进行编译,但也常常遇到不如直接调用更加方便的情况.那么这时候,我个人需要 ...

  2. 学习笔记48_Memcache跟用户登录模块结合

    public interface ICacheWriter {  void AddCache(string key,object value, DateTime expDate);  void Add ...

  3. Python 中 -m 的典型用法、原理解析与发展演变

    在命令行中使用 Python 时,它可以接收大约 20 个选项(option),语法格式如下: python [-bBdEhiIOqsSuvVWx?] [-c command | -m module- ...

  4. CSPS模拟 81

    Z哥的题,真是见题如见人啊.. T1 实际状态数没有那么多,不要被数字吓倒就是了. 另外为什么吧轮廓线给忘了啊 T3 觉得自己是正解但是被hack了? 考试的时候想到了复杂度对的的解法,但是 spfa ...

  5. Can't connect to MySQL server on 'localhost' (10061),连接Navicat报错问题解决

    今天,装了Mysql 1.1.7后,连接Navicat 时报错,后来找了一阵,发现问题所在. 原因是我在安装时把默认端口号3306修改成了3303, 连接时,把默认端口也修改下就好啦.

  6. nginx recv() failed (104: Connection reset by peer) while reading response header from upstream解决方法

    首先说下 先看 按照ab 每秒请求的结果 看看 都有每秒能请求几个 如果并发量超出你请求的个数 会这样 所以一般图片和代码服务器最好分开 还有看看io瓶ding 和有没有延迟的PHP代码执行 0 先修 ...

  7. PHP failed to ptrace(PEEKDATA) pid 13659: Input/output error错误解决方法

    PHP failed to ptrace(PEEKDATA) pid 13659: Input/output error错误解决方法 现在改linux内核文件打开限制<pre>ulimit ...

  8. jquey写进度条问题

    jquey写进度条问题可以直接按照 总时间和进度条宽度之比来做 不管他是不是y=kx 反正时间到0 进度肯定是0了

  9. Python 基础之socket编程(一)

    Python 基础之socket编程(一) 可以进行通信玩儿了,感觉不错不错,网络通信就像打电话,我说一句你听一句之后,你再说一句,我听一句,就这样.....下去了.不扯淡了,来来来,看看今天都搞了点 ...

  10. 50行Python代码实现视频中物体颜色识别和跟踪(必须以红色为例)

    目前计算机视觉(CV)与自然语言处理(NLP)及语音识别并列为人工智能三大热点方向,而计算机视觉中的对象检测(objectdetection)应用非常广泛,比如自动驾驶.视频监控.工业质检.医疗诊断等 ...