/// <summary>
 ///Populates a <see cref="System.Runtime.Serialization.SerializationInfo"/> with the data needed to serialize the target object.
 /// </summary>
 /// <param name="info">The <see cref="System.Runtime.Serialization.SerializationInfo"/> to populate with data. </param>
 /// <param name="context">The destination (see <see cref="System.Runtime.Serialization.StreamingContext"/>) for this serialization. </param>
 public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
 {
     lock (_putLock) {
         lock (_takeLock) {
             SerializationUtilities.DefaultWriteObject(info, context, this);
             info.AddValue("Data", ToArray());
         }
     }
 }
        /// <summary>
        /// Save the state of the instance to a stream (that
        /// is, serialize it).
        /// </summary>
        /// <serialData> The length of the array backing the instance is
        /// emitted (int), followed by all of its elements (each an
        /// <see cref="System.Object"/>) in the proper order.
        /// </serialData>
        /// <param name="serializationInfo">the stream</param>
        /// <param name="context">the context</param>
        public virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext context)
        {
            SerializationUtilities.DefaultWriteObject(serializationInfo, context, this);

            // Write out array length
            serializationInfo.AddValue("Length", _queue.Length);

            // Write out all elements in the proper order.
            serializationInfo.AddValue("Data", ToArray());

            // Writer out the comparer if not the _defaultComparer.
            serializationInfo.AddValue("Comparer", Comparer);
        }
예제 #3
0
        /// <summary> 
        /// Save the state of the list to a stream (i.e., serialize it).
        /// </summary>
        /// <serialData> The length of the array backing the list is emitted
        /// (int), followed by all of its elements (each an object)
        /// in the proper order.
        /// </serialData>
        /// <param name="s">the stream</param>
        /// <param name="context">the context</param>
        public void GetObjectData(SerializationInfo s, StreamingContext context) {
            // Write out element count, and any hidden stuff
            SerializationUtilities.DefaultWriteObject(s, context, this);

            T[] elements = Array;
            int len = elements.Length;
            // Write out array length
            s.AddValue("Spring.Threading.Collections.CopyOnWriteArrayListdataLength", len);

            // Write out all elements in the proper order.
            for(int i = 0; i < len; i++) {
                s.AddValue("Spring.Threading.Collections.CopyOnWriteArrayListdata" + i, elements[i]);
            }
        }