public string ReadINI(string section, string value) { Utils.Script($"{MethodBase.GetCurrentMethod().Name} got called"); if (!Framework.Settings.ScriptExecutionSettings.ReadINIWithInterface) { return(OblivionINI.GetINIValue(section, value)); } var s = _handler.ScriptFunctions.ReadOblivionINI(section, value); return(s ?? throw new OMODFrameworkException( "Could not read the oblivion.ini file using the function IScriptFunctions.ReadOblivionINI")); }
public void TestOblivionINI_Set() { const string file = "oblivion-test-ini-set.ini"; const string contents = "[General]\nname=Peter Griffin\nage=18 ;very important!"; File.WriteAllText(file, contents, Encoding.UTF8); OblivionINI.SetINIValue(file, "General", "age", "22"); var newValue = OblivionINI.GetINIValue(file, "General", "age"); Assert.Equal("22", newValue); }
public void TestOblivionINI_Get_File() { const string file = "oblivion-test-ini.ini"; const string contents = "[General]\nname=Peter Griffin\nage=18 ;very important!"; File.WriteAllText(file, contents, Encoding.UTF8); var name = OblivionINI.GetINIValue(file, "general", "Name"); var age = OblivionINI.GetINIValue(file, "gENeRaL", "aGe"); var nothing = OblivionINI.GetINIValue(file, "General", "Address"); Assert.Equal("Peter Griffin", name); Assert.Equal("18", age); Assert.Null(nothing); }
public void TestOblivionINI_Get_Stream() { const string contents = "[General]\nname=Peter Griffin\nage=18 ;very important!"; var bytes = Encoding.UTF8.GetBytes(contents); using var ms = new MemoryStream(bytes.Length); ms.Write(bytes, 0, bytes.Length); ms.Position = 0; var name = OblivionINI.GetINIValue(ms, "general", "Name", "TestCacheName"); var age = OblivionINI.GetINIValue(ms, "gENeRaL", "aGe", "TestCacheName"); var nothing = OblivionINI.GetINIValue(ms, "General", "Address", "TestCacheName"); Assert.Equal("Peter Griffin", name); Assert.Equal("18", age); Assert.Null(nothing); }