private void serializeObjects(List <IModelObject> list, StreamWriter wr)
        {
            //       // TODO: Haxor for debug info!!!
            //strm.WriteLine((string)obj.GetType().GetField("DEBUG_CREATEDBY", BindingFlags.NonPublic| BindingFlags.Instance).GetValue(obj));
            //(string)obj.GetType().GetField("DEBUG_CREATEDBY", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(obj,reader.ReadLine());
            //// TODO: Haxor for debug info!!!
            //strm.WriteLine(.GetValue(obj));

            var strm = new SectionedStreamWriter(wr);

            myObjectDictionary.Clear();

            // Write all objects
            strm.EnterSection(ObjectsSection);
            foreach (var obj in list)
            {
                var id = myObjectDictionary.getObjectID(obj);
                strm.WriteLine(id.ToString());
                strm.WriteLine(typeSerializer.Serialize(obj.GetType()));
            }
            strm.ExitSection();

            // Write all attributes
            strm.EnterSection(AttributesSection);
            foreach (var obj in list)
            {
                var id = myObjectDictionary.getObjectID(obj);
                strm.WriteLine(id.ToString());
                SerializeAttributes(obj, strm);
            }
            strm.ExitSection();
        }
        /// <summary>
        /// Writes a string serialized attribute value to the stream
        /// </summary>
        /// <param name="strm"></param>
        /// <param name="serialized"></param>
        private static void writeAttributeData(SectionedStreamWriter strm, string serialized)
        {
            if (serialized.Contains('\n'))
            {
                var sublength = serialized.Length;
                if (serialized[serialized.Length - 1] == '\n')
                {
                    sublength--;
                }
                else
                {
                    throw new InvalidOperationException(
                              "Provided serialized data cannot be used since it doesnt end with \n");
                }
                if (serialized[serialized.Length - 2] == '\r')
                {
                    sublength--;
                }


                // Write section
                strm.EnterSection("AttributeData");
                strm.WriteLine(serialized.Substring(0, sublength));
                strm.ExitSection();
            }
            else
            {
                strm.WriteLine(serialized);
            }
        }
        /// <summary>
        /// Writes an entire attribute
        /// </summary>
        private void writeAttribute(SectionedStreamWriter strm, IAttribute att, object value)
        {
            strm.WriteLine(att.Name);
            var serialized = serializeAttribute(att, value);

            if (serialized == StringSerializer.Unknown)
            {
                Console.WriteLine("Cannot serialize type: {0}", value.GetType().FullName);
            }
            writeAttributeData(strm, serialized);
        }