public static Save ( |
||
writer | ||
values | Value>.IDictionary | |
리턴 | void |
private void StateSave(string path) { Dictionary <string, Value> values = new Dictionary <string, Value> (); foreach (TreeNode root in this.treeViewValue.Nodes) { foreach (KeyValuePair <Value, Value> pair in this.ValuesBuild(root.Nodes)) { values[pair.Key.AsString] = pair.Value; } } try { using (BinaryWriter writer = new BinaryWriter(new FileStream(path, FileMode.Create), Encoding.UTF8)) { writer.Write(2); ValueAccessor.Save(writer, values); writer.Write(this.parameters.BlockBegin); writer.Write(this.parameters.BlockContinue); writer.Write(this.parameters.BlockEnd); writer.Write(this.parameters.TrimmerIndex); writer.Write(this.textBoxInput.Text); } MessageBox.Show(this, string.Format(CultureInfo.InvariantCulture, "State successfully saved to \"{0}\".", path), "File save successfull", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show(this, string.Format(CultureInfo.InvariantCulture, "Cannot open output file \"{0}\"", path), "File save error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private static void Save(BinaryWriter writer, Value value) { writer.Write((int)value.Type); switch (value.Type) { case ValueContent.Boolean: writer.Write(value.AsBoolean); break; case ValueContent.Map: writer.Write(value.Fields.Count); foreach (KeyValuePair <Value, Value> pair in value.Fields) { ValueAccessor.Save(writer, pair.Key); ValueAccessor.Save(writer, pair.Value); } break; case ValueContent.Number: writer.Write(value.AsNumber); break; case ValueContent.String: writer.Write(value.AsString); break; } }
public static void Save(BinaryWriter writer, IDictionary <string, Value> values) { writer.Write(values.Count); foreach (KeyValuePair <string, Value> pair in values) { writer.Write(pair.Key); ValueAccessor.Save(writer, pair.Value); } }