public static GlobalConfigData getDefault() { GlobalConfigData data = new GlobalConfigData(); data.robotsPerPlayer = 3; data.robotSpawnRatePerSecond = 1f; data.spawnRateIncreasePerPlayer = 0.1f; return data; }
public void LoadGlobalConfigDataTest() { ConfigManager.LoadGlobalConfigData(); GlobalConfigData data = ConfigManager.GlobalConfigData; Assert.IsNotNull(data); ShowConfigData(data); }
/// <summary> /// Gets the lastest data from json configuration file /// </summary> /// <returns></returns> /// <exception cref="GlobalConfigDataProviderException"></exception> public GlobalConfigData GetFreshData() { try { string jsonGlobalSettings = System.IO.File.ReadAllText(System.IO.Path.Combine(Env.Hosting.ContentRootPath, _jsonPath)); GlobalConfigData configData = JsonConvert.DeserializeObject <GlobalConfigData>(jsonGlobalSettings); return(configData); } catch (Exception ex) { throw new GlobalConfigDataProviderException(ex); } }
public void SaveData(GlobalConfigData dataToSave) { string jsonGlobalSettingsPath = GetGlobalJsonFilePath(); string convertedDataToSave = JsonConvert.SerializeObject(dataToSave, Formatting.Indented); try { System.IO.File.WriteAllText(jsonGlobalSettingsPath, convertedDataToSave); } catch (Exception ex) { throw new GlobalConfigDataProviderException(ex); } }
public void CreateConfigFile() { GlobalConfigData globalConfigData = new GlobalConfigData(); globalConfigData.AddConfigRoot("GlobalConfig"); globalConfigData.AddConfigItem("GlobalConfig", "PlatformEncoding", Encoding.UTF8.BodyName); globalConfigData.AddConfigItem("GlobalConfig", "PlatformLibDir", @"lib\"); // globalConfigData.AddConfigItem("GlobalConfig", "WorkspaceDir", @"C:\Users\jingtao\Documents\TestflowWorkspace"); globalConfigData.AddConfigItem("GlobalConfig", "DotNetVersion", @"v4.0.30319"); globalConfigData.AddConfigItem("GlobalConfig", "LogLevel", LogLevel.Info); globalConfigData.AddConfigRoot("EngineCore"); globalConfigData.AddConfigItem("EngineCore", "TestGenReportInterval", 500); globalConfigData.AddConfigItem("EngineCore", "TestRunReportInterval", 500); globalConfigData.AddConfigItem("EngineCore", "EngineQueueFormat", FormatterType.Json); globalConfigData.AddConfigItem("EngineCore", "EngineSyncMessenger", true); globalConfigData.AddConfigItem("EngineCore", "MessageReceiveTimeout", 10000); globalConfigData.AddConfigItem("EngineCore", "StatusUploadInterval", 500); globalConfigData.AddConfigItem("EngineCore", "ConnectionTimeout", 10000); globalConfigData.AddConfigItem("EngineCore", "SyncTimeout", 10000); globalConfigData.AddConfigItem("EngineCore", "TestTimeout", 1000000000); globalConfigData.AddConfigItem("EngineCore", "StopTimeout", 10000); globalConfigData.AddConfigItem("EngineCore", "TestGenTimeout", 5000); globalConfigData.AddConfigItem("EngineCore", "AbortTimeout", 10000); globalConfigData.AddConfigItem("EngineCore", "MessengerType", MessengerType.MSMQ); globalConfigData.AddConfigItem("EngineCore", "EnablePerformanceMonitor", false); globalConfigData.AddConfigItem("EngineCore", "NumericFormat", "0.#####"); globalConfigData.AddConfigRoot("DataMaintain"); globalConfigData.AddConfigItem("DataMaintain", "DatabaseName", "testflowData.db3"); globalConfigData.AddConfigRoot("ResultManager"); globalConfigData.AddConfigRoot("SequenceInfo"); globalConfigData.AddConfigItem("SequenceInfo", "ModelVersion", "1.0.0.0"); globalConfigData.AddConfigItem("SequenceInfo", "FileEncoding", Encoding.UTF8.ToString()); globalConfigData.AddConfigRoot("ParameterCheck"); globalConfigData.AddConfigRoot("InterfaceLoad"); ConfigData configData = globalConfigData.GetConfigData(); configData.ConfigVersion = "1.0.0.0"; FileStream fileStream = new FileStream("config.xml", FileMode.Create); XmlSerializer xmlSerializer = new XmlSerializer(typeof(ConfigData), new Type[] { typeof(ConfigData), typeof(ConfigBlock), typeof(ConfigItem) }); xmlSerializer.Serialize(fileStream, configData); }
public override void LoadContent() { outputPos = MyGame.Manager.TextManager.GetTextPosition(0, 4); GlobalConfigData data = MyGame.Manager.ConfigManager.GlobalConfigData; enemysPos = new Vector2(data.EnemysX, data.EnemysY); Single x = (120 - 64) / 2.0f + data.EnemysX; Single y = (120 - 64) / 2.0f + data.EnemysY; targetPos = new Vector2(x - 0, y - 0); enemysRect = MyGame.Manager.ImageManager.EnemyRectangles[7]; targetRect = MyGame.Manager.ImageManager.TargetLargeRectangle; base.LoadContent(); }
// Use this for initialization public void Start() { serverConfig = GlobalConfig.globalConfig.configuration; pause(); currentMenu = state.MainMenu; }
internal static GlobalConfigData ReadGlobalFile(string configFilePath, GlobalConfigData config, ConfigLoadingWindow configLoadingWindow) { Sections curSection = Sections.Void; int totalLines = File.ReadLines(configFilePath).Count(); using (StreamReader sr = new StreamReader(configFilePath)) { int lineNumber = 0; string line; while (sr.Peek() > -1) { line = sr.ReadLine().Trim(); ++lineNumber; configLoadingWindow.SetLinesProgress(lineNumber, totalLines); //NOTE(adam): if is blank line or comment, skip if (!(line.Length > 0 && line[0] != '#')) { continue; } //NOTE(adam): set section or parse line based on current section if (line[0] == '>') { if (line.Contains("ROOT")) { curSection = Sections.Root; ErrorHandler.HandleError(ErrorType.Log, $"config {lineNumber}: Should not have {curSection} in gloabl file."); } else if (line.Contains("EXTENSION")) { curSection = Sections.Extension; ErrorHandler.HandleError(ErrorType.Log, $"config {lineNumber}: Should not have {curSection} in gloabl file."); } else if (line.Contains("TYPES")) { curSection = Sections.Types; ErrorHandler.HandleError(ErrorType.Log, $"config {lineNumber}: Should not have {curSection} in gloabl file."); } else if (line.Contains("PREFIXES")) { curSection = Sections.Prefixes; } else if (line.Contains("PATHS")) { curSection = Sections.Paths; ErrorHandler.HandleError(ErrorType.Log, $"config {lineNumber}: Should not have {curSection} in gloabl file."); } else if (line.Contains("EXPORTS")) { curSection = Sections.Exports; ErrorHandler.HandleError(ErrorType.Log, $"config {lineNumber}: Should not have {curSection} in gloabl file."); } else if (line.Contains("EXCEPTIONS")) { curSection = Sections.Exceptions; ErrorHandler.HandleError(ErrorType.Log, $"config {lineNumber}: Should not have {curSection} in gloabl file."); } else if (line.Contains("TRIMS")) { curSection = Sections.Trims; } else { ErrorHandler.HandleError(ErrorType.Log, $"config {lineNumber}: Invalid section header."); } } else { switch (curSection) { case Sections.Root: //NOTE(adam): invalid section for global, logged when section set break; case Sections.Extension: //NOTE(adam): invalid section for global, logged when section set break; case Sections.Types: //NOTE(adam): invalid section for global, logged when section set break; case Sections.Prefixes: config.InsertStylePrefix(line); break; case Sections.Paths: //NOTE(adam): invalid section for global, logged when section set break; case Sections.Exports: //NOTE(adam): invalid section for global, logged when section set break; case Sections.Exceptions: //NOTE(adam): invalid section for global, logged when section set break; case Sections.Trims: config.InsertTrim(line); break; default: ErrorHandler.HandleError(ErrorType.Log, $"config {lineNumber}: Unspecified section."); break; } } } } return(config); }