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. centOS7 永久关闭防火墙

    查看防火墙状态: systemctl status firewalld.service 如图 绿的running表示防火墙开启 执行关闭命令: systemctl stop firewalld.ser ...

  2. Python基础知识-运算符

    今日学习内容 用户交互 用户交互就是人向机器发出指令,机器分析处理后,给人们返回操作结果(装13的说法).直白地讲,就是人往计算机中输入(input)数据,计算机输出(output)结果.交互的本质就 ...

  3. 第三十四章 POSIX消息队列

    POSIX消息队列相关函数 mq_open 功能: 用来创建和访问一个消息队列 原型: mqd_t mq_open(const char *name, int oflag); //只能用来打开消息队列 ...

  4. 第二十五章 system v消息队列(一)

    IPC对象的持续性 随进程持续 :一直存在直到打开的最后一个进程结束.(如pipe和FIFO) 随内核持续 :一直存在直到内核自举(内核自举就是把主引导记录加载到内存,并跳转执行这段内存)或显示删除( ...

  5. 前端技术之:webpack热模块替换(HMR)

    第一步:安装HMR中间件: npm install --save-dev webpack-hot-middleware   第二步:webpack配置中引入webpack对象     const we ...

  6. 暑期集训20190807 游戏(game)

    [问题描述] 小A 拿到了 n 个数,

  7. Pandas 转换连接

    # 导入相关库 import numpy as np import pandas as pd 拼接 有两个 DataFrame,都存储了用户的一些信息,现在要拼接起来,组成一个 DataFrame. ...

  8. 三分钟学会Redis在.NET Core中做缓存中间件

    大家好,今天给大家说明如何在.NET Core中使用Redis,我们在想要辩论程序的好与坏,都想需要一个可视化工具,我经常使用的是一位国内大牛开发的免费工具,其Github地址为: https://g ...

  9. 使用Typescript重构axios(三十)——添加axios.getUri方法

    0. 系列文章 1.使用Typescript重构axios(一)--写在最前面 2.使用Typescript重构axios(二)--项目起手,跑通流程 3.使用Typescript重构axios(三) ...

  10. 安全路径——最短路径树+dsu缩边

    题目描述 思路 首先想到$dijkstra$跑完之后$build$一棵最短路径树.要找到每个节点i到根的满足要求的最短路,考虑把一些非树边加进去. 对于非树边$(u,v)$,因为节点i上方的边被占领, ...