private static void Initialize() { if (!_initialized) { lock (_initLock) { if (!_initialized) { try { RadianceSection section = ConfigurationManager.GetSection("radiance") as RadianceSection; if (section != null) { _connectionString = ConfigurationManager.ConnectionStrings[section.ConnectionStringName].ConnectionString; _worldName = section.WorldName; } } catch (Exception ex) { _initException = ex; } _initialized = true; } } } if (_initException != null) { throw _initException; } }
/// <summary> /// Initializes a new server instance and loads the virtual world from the specified configuration section. /// </summary> /// <param name="configSection">The RadianceSection to use in loading the virtual world.</param> public Server(RadianceSection configSection) { this.Clients = new ClientManager(); this.Clients.ClientAdded += (o, e) => { if (_serverTimer != null && !_serverTimer.Enabled) { _serverTimer.Start(); } }; this.Initialize(configSection); }
private void Initialize(RadianceSection section) { if (section != null) { this.CommandsModuleName = section.Script.CommandsModuleName; this.EventsModuleName = section.Script.EventsModuleName; this.World = Activator.CreateInstance(Type.GetType(section.World.WorldType)) as World; if (this.World != null) { this.World.Server = this; this.World.ConfigureWorld(section.World); CommandManager.Initialize(section.Command); Log.Initialize(section.Log); Radiance.Security.Cryptography.Initialize(section.Cryptography); // Load modules. if (section.Modules != null) { _modules.Clear(); foreach (var element in section.Modules) { var moduleElement = (ModuleElement)element; var module = Activator.CreateInstance(Type.GetType(moduleElement.Type)) as IModule; _modules.Add(module); } } } else { throw new Exception(SR.ConfigWorldTypeNotFound(section.World.WorldType)); } } else { throw new Exception(SR.ConfigRadianceSectionNotFound); } }