本文整理汇总了C#中IServerConfig类的典型用法代码示例。如果您正苦于以下问题:C# IServerConfig类的具体用法?C# IServerConfig怎么用?C# IServerConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IServerConfig类属于命名空间,在下文中一共展示了IServerConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
/// <summary>
/// Setups the specified root config.
/// </summary>
/// <param name="bootstrap">The bootstrap.</param>
/// <param name="config">The socket server instance config.</param>
/// <param name="factories">The factories.</param>
/// <returns></returns>
public bool Setup(IBootstrap bootstrap, IServerConfig config, ProviderFactoryInfo[] factories)
{
m_Bootstrap = bootstrap;
m_ServerConfig = config;
m_Factories = factories;
return true;
}
示例2: GetAppServerMetadata
protected override AppServerMetadata GetAppServerMetadata(IServerConfig serverConfig)
{
AppDomain validateDomain = null;
AppServerMetadata metadata = null;
try
{
validateDomain = AppDomain.CreateDomain("ValidationDomain", AppDomain.CurrentDomain.Evidence, serverConfig.Options.Get("appWorkingDir") ?? IsolationApp.GetAppWorkingDir(serverConfig.Name), string.Empty, false);
AssemblyImport.RegisterAssembplyImport(validateDomain);
validateDomain.SetData(typeof(IsolationMode).Name, ConfigSource.Isolation);
var validatorType = typeof(RemoteAppTypeValidator);
var validator = (RemoteAppTypeValidator)validateDomain.CreateInstanceAndUnwrap(validatorType.Assembly.FullName, validatorType.FullName);
var result = validator.GetServerMetadata(serverConfig.Type);
if(!result.Result)
{
Logger.Error(result.Message);
return null;
}
metadata = result.Value;
}
finally
{
if (validateDomain != null)
AppDomain.Unload(validateDomain);
}
return metadata;
}
示例3: Composite
private bool Composite(IServerConfig config)
{
CompositionContainer = GetCompositionContainer(config);
//Fill the imports of this object
try
{
var targets = new List<ICompositeTarget>();
RegisterCompositeTarget(targets);
if (targets.Any())
{
foreach (var t in targets)
{
if(!t.Resolve(this, CompositionContainer))
{
throw new Exception("Failed to resolve the instance of the type: " + t.GetType().FullName);
}
}
}
return true;
}
catch(Exception e)
{
var logger = Logger;
if (logger == null)
throw e;
logger.Error("Composition error", e);
return false;
}
}
示例4: Start
/// <summary>
/// Starts to listen
/// </summary>
/// <param name="config">The server config.</param>
/// <returns></returns>
public override bool Start(IServerConfig config)
{
try
{
m_ListenSocket = new Socket(this.EndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
m_ListenSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
m_ListenSocket.Bind(this.EndPoint);
//Mono doesn't support it
if (Platform.SupportSocketIOControlByCodeEnum)
{
uint IOC_IN = 0x80000000;
uint IOC_VENDOR = 0x18000000;
uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12;
byte[] optionInValue = { Convert.ToByte(false) };
byte[] optionOutValue = new byte[4];
m_ListenSocket.IOControl((int)SIO_UDP_CONNRESET, optionInValue, optionOutValue);
}
var eventArgs = m_SaePool.Get();
m_ListenSocket.ReceiveFromAsync(eventArgs);
return true;
}
catch (Exception e)
{
OnError(e);
return false;
}
}
示例5: Setup
public virtual bool Setup(IBootstrap bootstrap, IServerConfig config)
{
Bootstrap = bootstrap;
var loggerProvider = bootstrap as ILoggerProvider;
if (loggerProvider != null)
Logger = loggerProvider.Logger;
State = ServerState.Initializing;
Config = config;
Name = config.Name;
State = ServerState.NotStarted;
AppWorkingDir = config.Options.Get("appWorkingDir") ?? GetAppWorkingDir(Name);
if (!Directory.Exists(AppWorkingDir))
Directory.CreateDirectory(AppWorkingDir);
var appConfigFilePath = GetAppConfigFile();
// use the application's own config file if it has
//AppRoot\AppName\App.config
if (!string.IsNullOrEmpty(appConfigFilePath))
StartupConfigFile = appConfigFilePath;
m_NotStartedStatus = new Lazy<StatusInfoCollection>(() =>
{
var status = new StatusInfoCollection(m_Metadata.Name);
status[StatusInfoKeys.IsRunning] = false;
return status;
});
return true;
}
示例6: Start
/// <summary>
/// 启动监听
/// </summary>
/// <param name="config">服务器配置</param>
/// <returns></returns>
public override bool Start(IServerConfig config)
{
m_ListenSocket = new System.Net.Sockets.Socket(this.Info.EndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
try
{
//关联终结地
m_ListenSocket.Bind(this.Info.EndPoint);
//设置监听最大连接数
m_ListenSocket.Listen(m_ListenBackLog);
m_ListenSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
m_ListenSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
//初始化套接字操作
SocketAsyncEventArgs acceptEventArg = new SocketAsyncEventArgs();
m_AcceptSAE = acceptEventArg;
//定义一个连接完成事件
acceptEventArg.Completed += new EventHandler<SocketAsyncEventArgs>(acceptEventArg_Completed);
if (!m_ListenSocket.AcceptAsync(acceptEventArg))
{
ProcessAccept(acceptEventArg);
}
return true;
}
catch (Exception e)
{
OnError(e);
return false;
}
}
示例7: ConfigInfo
public ConfigInfo(IServerConfig serverConfig, ClientConfiguration clientConfig)
{
ServerConfig = serverConfig;
ClientConfig = clientConfig;
CreationTime = DateTime.Now;
Initialize();
}
示例8: ReportPotentialConfigChange
public void ReportPotentialConfigChange(IServerConfig config)
{
foreach (var item in Items)
{
item.ReportPotentialConfigChange(config);
}
}
示例9: SetUp
public void SetUp() {
serverConfig = A.Fake<IServerConfig>();
directoryEntryFactory = A.Fake<IDirectoryEntryFactory>();
filterBuilde = new FilterBuilder(serverConfig);
nameParser = new NameParser();
adapter = new DirectoryEntryAdapter(serverConfig, directoryEntryFactory, filterBuilde, nameParser);
}
示例10: Start
/// <summary>
/// Starts to listen
/// </summary>
/// <param name="config">The server config.</param>
/// <returns></returns>
public override bool Start(IServerConfig config)
{
try
{
m_ListenSocket = new Socket(this.EndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
m_ListenSocket.Bind(this.EndPoint);
uint IOC_IN = 0x80000000;
uint IOC_VENDOR = 0x18000000;
uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12;
byte[] optionInValue = { Convert.ToByte(false) };
byte[] optionOutValue = new byte[4];
m_ListenSocket.IOControl((int)SIO_UDP_CONNRESET, optionInValue, optionOutValue);
var eventArgs = new SocketAsyncEventArgs();
eventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(eventArgs_Completed);
eventArgs.RemoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
int receiveBufferSize = config.ReceiveBufferSize <= 0 ? 2048 : config.ReceiveBufferSize;
var buffer = new byte[receiveBufferSize];
eventArgs.SetBuffer(buffer, 0, buffer.Length);
m_ListenSocket.ReceiveFromAsync(eventArgs);
return true;
}
catch (Exception e)
{
OnError(e);
return false;
}
}
示例11: Start
/// <summary>
/// Starts to listen
/// </summary>
/// <param name="config">The server config.</param>
/// <returns></returns>
public override bool Start(IServerConfig config)
{
m_ListenSocket = new Socket(this.Info.EndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
try
{
m_ListenSocket.Bind(this.Info.EndPoint);
m_ListenSocket.Listen(m_ListenBackLog);
m_ListenSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
m_ListenSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
//
m_ListenSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
SocketAsyncEventArgs acceptEventArg = new SocketAsyncEventArgs();
acceptEventArg.Completed += new EventHandler<SocketAsyncEventArgs>(acceptEventArg_Completed);
if (!m_ListenSocket.AcceptAsync(acceptEventArg))
ProcessAccept(acceptEventArg);
return true;
}
catch (Exception e)
{
OnError(e);
return false;
}
}
示例12: Init
public override bool Init(FtpServer server, IServerConfig config)
{
if (!base.Init(server, config))
return false;
var userSettingFile = config.Options.GetValue("userSetting");
if (string.IsNullOrEmpty(userSettingFile))
{
server.Logger.Error("No user setting file was not defined!");
return false;
}
if (!Path.IsPathRooted(userSettingFile))
userSettingFile = server.GetFilePath(userSettingFile);
if (!File.Exists(userSettingFile))
{
AppServer.Logger.Error("The userSetting file cannot be found!");
return false;
}
m_UserConfigFile = userSettingFile;
ReadUserConfigFile();
m_UserConfigReadTimer = new Timer(OnUserConfigReadTimerCallback, null, Timeout.Infinite, Timeout.Infinite);
return true;
}
示例13: AddNewServer
bool IDynamicBootstrap.AddAndStart(IServerConfig config)
{
var newWorkItem = AddNewServer(config);
if (newWorkItem == null)
return false;
return newWorkItem.Start();
}
示例14: ClusterManager
internal ClusterManager(ClientConfiguration clientConfig, IServerConfig serverConfig, HttpClient httpClient, IDataMapper mapper, string username, string password)
{
_clientConfig = clientConfig;
_serverConfig = serverConfig;
Mapper = mapper;
HttpClient = httpClient;
_password = password;
_username = username;
}
示例15: ConfigUtil
static ConfigUtil()
{
ServerConfig = new FileSystemConfig(BootstrapPath);
ServerConfig.Initialize();
ClientConfig = new FakeClientConfig();
}