/// <summary>
        /// Captures the future data.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="header">The header.</param>
        /// <param name="instance">The instance.</param>
        public void CaptureFutureData <T>(BarfObjectHeader header, ref T instance)
            where T : ISerializationInfo
        {
            if (header.EndPosition < Reader.BaseStream.Position)
            {
                RaiseInvalidData <T>(header, "Can't capture future data when the current position is past the current position.");
            }

            var remainingLength = header.EndPosition - Reader.BaseStream.Position;
            var futureData      = new byte[remainingLength];

            Reader.BaseStream.Read(futureData, 0, futureData.Length);

            var typeInfo = BarfSerializationTypeInfo.Create(header, futureData);

            var info = (BarfSerializationInfo)instance.SerializationInfo ?? new BarfSerializationInfo();

            info.Add(typeof(T), typeInfo);

            instance.SerializationInfo = info;
        }
Ejemplo n.º 2
0
 public void Add(Type type, BarfSerializationTypeInfo info)
 {
     _perTypeInfo.Add(type, info);
 }
Ejemplo n.º 3
0
 public bool TryGet(Type type, out BarfSerializationTypeInfo info)
 {
     return(_perTypeInfo.TryGetValue(type, out info));
 }