public void ReadStream_WhenArgIsFileStreamAndNoConfigGiven_ReadsFileCorrectly() { using (var s = GetStream()) { var tml = Toml.ReadStream(GetStream()); tml.Get <int>("X").Should().Be(1); } }
public void ReadStreamOfT_WhenNoConfigGiven_ReadsFileCorrectly() { using (var s = GetStream()) { var tml = Toml.ReadStream <SimpleToml>(GetStream()); tml.X.Should().Be(1); } }
public void ReadStreamOfT_WhenConfigIsNull_ThrowsArgNull() { using (var s = GetStream()) { Action a = () => Toml.ReadStream <SimpleToml>(GetStream(), null); a.ShouldThrow <ArgumentNullException>(); } }
public static InitialState LoadDefault(Skills skillConfig) { Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LS.Core.Configuration.InitialState.tml"); InitialState state = Toml.ReadStream <InitialState> (stream); state.SkillConfig = skillConfig; return(state); }
public IDictionary <string, string> Parse(Stream stream) { data.Clear(); context.Clear(); Toml.ReadStream(stream).Visit(this); return(data); }
public void WriteStream_WithConfig_WritesToStream() { using (var s = new MemoryStream()) { Toml.WriteStream(CreateFoo(), s, TomlSettings.Create()); var read = Toml.ReadStream <Foo>(s); read.X.Should().Be(1); } }
public void LoadStrings(Stream stream) { var table = Toml.ReadStream(stream); foreach (var key in table.Keys) { var value = table.Get <TomlString>(key).Value; strings.Add(key, value); } }
/// <summary> /// Reads in quest tasks from a filestream where tasks are written in the TOML file format /// </summary> /// <returns>Tasks read in from file in the form of a list of Temporary Tasks</returns> /// <param name="fileStream">File stream to be read from.</param> private List <TemporaryTask> ReadInTasks(Stream fileStream) { QuestFileRoot root = Toml.ReadStream <QuestFileRoot>(fileStream); foreach (var task in root.task) { if (!task.IsValid()) { throw new System.Exception("Found invalid task when reading file. Ensure that each task has a nonempty name."); } } return(root.task); }
public override void Load(Stream stream) { var table = Toml.ReadStream(stream); if (this.CaseInsensitiveKeys) { this.Data = ProviderDictionaryConverter.ToProviderDictionary(table, StringComparer.OrdinalIgnoreCase); } else { this.Data = ProviderDictionaryConverter.ToProviderDictionary(table); } }
/// <summary> /// Loads in player's state through quests in TOML file format /// </summary> /// <returns>(Incomplete) dictionary of task names to completion status</returns> /// <param name="fileStream">File stream to read from.</param> public Dictionary <string, bool> LoadQuestState(Stream fileStream) { Dictionary <string, bool> taskDictionary = new Dictionary <string, bool>(); TomlTable tomlTable = Toml.ReadStream(fileStream); // string completedTasks = tomlTable.Get<string>("CompletedTask"); // completedTasks contains "PoundRice" var cT = tomlTable.TryGetValue("CompletedTask"); if (cT != null) { string[] completedTasks = cT.Get <string>().Split(' '); foreach (string task in completedTasks) { taskDictionary.Add(task, true); } } return(taskDictionary); }
public static ConfigData LoadDefault() { Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LS.Core.Configuration.Configuration.tml"); return(Toml.ReadStream <ConfigData> (stream)); }
public override void Load(Stream stream) { var table = Toml.ReadStream(stream); this.Data = this.ToProviderDictionary(table); }
public static Behaviors LoadDefault() { Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LS.Core.Configuration.Behavior.tml"); return(Toml.ReadStream <Behaviors> (stream)); }