public static void Save(string account, string server, string name) { LastCharacterInfo lastChar = LastCharacters.FirstOrDefault(c => c.AccountName.Equals(account) && c.ServerName == server); // Check to see if they passed in -lastcharactername but picked another character, clear override then if (!string.IsNullOrEmpty(LastCharacterNameOverride) && !LastCharacterNameOverride.Equals(name)) { LastCharacterNameOverride = string.Empty; } if (lastChar != null) { lastChar.LastCharacterName = name; } else { LastCharacters.Add(new LastCharacterInfo { ServerName = server, LastCharacterName = name, AccountName = account }); } ConfigurationResolver.Save(LastCharacters, _lastCharacterFile); }
public void Set_configrationSection_then_read() { var section1 = new CacheConfigurationSection { Pattern = "{region}/{key}", FormatNullRegion = true, MaxExpirationHour = 1D, Details = new CacheItemElementCollection() }; section1.Details.Add(new CacheItemDetailElement { Region = "someRegion", Pattern = "{region}//{key}", Provider = typeof(RedisCacheProvider).FullName, FormatNullRegion = false, }); var resolver = new ConfigurationResolver(); resolver.ExeConfigFilename = "test.config"; resolver.Save(section1, "cacheBuilder"); var section2 = resolver.Read <CacheConfigurationSection>("cacheBuilder"); Assert.AreEqual(section2.Pattern, section1.Pattern); Assert.AreEqual(section2.FormatNullRegion, section1.FormatNullRegion); Assert.AreEqual(section2.MaxExpirationHour, section1.MaxExpirationHour); Assert.IsNotNull(section2.Details); Assert.AreEqual(section2.Details.Count, section1.Details.Count); Assert.AreEqual( section2.Details.Get(typeof(RedisCacheProvider).FullName), section1.Details.Get(typeof(RedisCacheProvider).FullName) ); }
public static void Load() { LastCharacters = new List <LastCharacterInfo>(); if (!File.Exists(_lastCharacterFile)) { ConfigurationResolver.Save(LastCharacters, _lastCharacterFile); } LastCharacters = ConfigurationResolver.Load <List <LastCharacterInfo> >(_lastCharacterFile); // safety check if (LastCharacters == null) { LastCharacters = new List <LastCharacterInfo>(); } }
protected override void Initialize() { Settings settings = ConfigurationResolver.Load <Settings>(Path.Combine(Bootstrap.ExeDirectory, "settings.json")); if (settings == null) { Log.Message(LogTypes.Trace, "settings.json file was not found creating default"); settings = new Settings(); ConfigurationResolver.Save(settings, "settings.json"); Process.Start("notepad.exe", "settings.json"); Exit(); return; } Service.Register(settings); Log.Message(LogTypes.Trace, "Checking for Ultima Online installation..."); try { FileManager.UoFolderPath = settings.UltimaOnlineDirectory; } catch (FileNotFoundException e) { Log.Message(LogTypes.Error, "Wrong Ultima Online installation folder."); throw e; } Log.Message(LogTypes.Trace, "Done!"); Log.Message(LogTypes.Trace, $"Ultima Online installation folder: {FileManager.UoFolderPath}"); Log.Message(LogTypes.Trace, "Loading files..."); Stopwatch stopwatch = Stopwatch.StartNew(); FileManager.LoadFiles(); uint[] hues = Hues.CreateShaderColors(); Texture2D texture0 = new Texture2D(GraphicsDevice, 32, Hues.HuesCount); texture0.SetData(hues, 0, 32 * Hues.HuesCount); Texture2D texture1 = new Texture2D(GraphicsDevice, 32, Hues.HuesCount); texture1.SetData(hues, 32 * Hues.HuesCount, 32 * Hues.HuesCount); GraphicsDevice.Textures[1] = texture0; GraphicsDevice.Textures[2] = texture1; Log.Message(LogTypes.Trace, $"Files loaded in: {stopwatch.ElapsedMilliseconds} ms!"); stopwatch.Stop(); InputManager.Initialize(); //Register Service Stack Service.Register(this); Service.Register(_sb3D = new SpriteBatch3D(GraphicsDevice)); Service.Register(_sbUI = new SpriteBatchUI(GraphicsDevice)); Service.Register(_uiManager = new UIManager()); //Register Command Stack Commands.Initialize(); Log.Message(LogTypes.Trace, "Network calibration..."); PacketHandlers.Load(); PacketsTable.AdjustPacketSizeByVersion(FileManager.ClientVersion); Log.Message(LogTypes.Trace, "Done!"); MaxFPS = settings.MaxFPS; _infoText = new RenderedText { IsUnicode = true, Font = 3, FontStyle = FontStyle.BlackBorder, Align = TEXT_ALIGN_TYPE.TS_LEFT, MaxWidth = 150 }; base.Initialize(); }
protected override void UnloadContent() { ConfigurationResolver.Save(Service.Get <Settings>(), "settings.json"); base.UnloadContent(); }