public static void Save(KeyValuesNode data, string path, FileMode mode) { using (FileStream str = new FileStream(path, mode)) { SaveNode(str, data); } }
public override void Add(KeyValuesNode node) { lock (this.childs) { KeyValuesNode exist = this[node.Name]; if (exist != null) { this.childs.Remove(exist); } this.childs.Add(node); } }
private static void SaveNode(FileStream st, KeyValuesNode cl) { if (cl.GetType() == typeof(KeyValuesCollection)) { SaveSection(st, (KeyValuesCollection)cl); } else if (cl.GetType() == typeof(KeyValuesPair<String>)) { KeyValuesPair<String> node = cl as KeyValuesPair<String>; st.WriteByte(TK_VAR_STRING); SaveString(st, node.Name); SaveString(st, node.Value); } else { byte[] dconv = null; if (cl.GetType() == typeof(KeyValuesPair<Int32>)) { st.WriteByte(TK_VAR_INT); dconv = BitConverter.GetBytes((cl as KeyValuesPair<Int32>).Value); } else if (cl.GetType() == typeof(KeyValuesPair<UInt32>)) { st.WriteByte(TK_VAR_INT); dconv = BitConverter.GetBytes((cl as KeyValuesPair<Int32>).Value); } else if (cl.GetType() == typeof(KeyValuesPair<Int64>)) { st.WriteByte(TK_VAR_INT); dconv = BitConverter.GetBytes((cl as KeyValuesPair<Int32>).Value); } else if (cl.GetType() == typeof(KeyValuesPair<UInt64>)) { st.WriteByte(TK_VAR_INT); dconv = BitConverter.GetBytes((cl as KeyValuesPair<Int32>).Value); } SaveString(st, cl.Name); st.Write(dconv, 0, dconv.Length); } }
public abstract void Add(KeyValuesNode node);