Exemple #1
0
 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);
            }
        }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
 public abstract void Add(KeyValuesNode node);