示例#1
0
        public virtual void Serialize(GMDataWriter writer, ListSerialize before = null,
                                      ListSerialize after             = null,
                                      ListSerializeElement elemWriter = null)
        {
            writer.Write(Count);
            for (int i = 0; i < Count; i++)
            {
                before?.Invoke(writer, i, Count);

                // Write the current element in the list
                if (elemWriter == null)
                {
                    this[i].Serialize(writer);
                }
                else
                {
                    elemWriter(writer, this[i]);
                }

                after?.Invoke(writer, i, Count);
            }
        }
示例#2
0
        public void Serialize(GMDataWriter writer, ListSerialize before = null,
                              ListSerialize after                    = null,
                              ListSerializeElement elemWriter        = null,
                              ListSerializeElement elemPointerWriter = null)
        {
            writer.Write(Count);

            // Write each element's pointer
            for (int i = 0; i < Count; i++)
            {
                if (elemPointerWriter == null)
                {
                    writer.WritePointer(this[i]);
                }
                else
                {
                    elemPointerWriter(writer, this[i]);
                }
            }

            // Write each element
            for (int i = 0; i < Count; i++)
            {
                before?.Invoke(writer, i, Count);

                // Write the current element in the list
                if (elemWriter == null)
                {
                    writer.WriteObjectPointer(this[i]);
                    this[i].Serialize(writer);
                }
                else
                {
                    elemWriter(writer, this[i]);
                }

                after?.Invoke(writer, i, Count);
            }
        }