Ejemplo n.º 1
0
 /// <summary>
 /// Puts a PooledBitReader back into the pool
 /// </summary>
 /// <param name="reader">The reader to put in the pool</param>
 public static void PutBackInPool(PooledBitReader reader)
 {
     if (readers.Count < 64)
     {
         readers.Enqueue(reader);
     }
     else if (LogHelper.CurrentLogLevel <= LogLevel.Developer)
     {
         LogHelper.LogInfo("BitReaderPool already has 64 queued. Throwing to GC. Did you forget to dispose?");
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads the contents from the stream and applies it to the type instance
        /// </summary>
        /// <param name="stream">The stream to read from</param>
        public virtual void Read(Stream stream)
        {
            FieldInfo[] fields = SerializationManager.GetFieldsForType(GetType());

            using (PooledBitReader reader = PooledBitReader.Get(stream))
            {
                for (int i = 0; i < fields.Length; i++)
                {
                    fields[i].SetValue(this, reader.ReadObjectPacked(fields[i].FieldType));
                }
            }
        }