IExtension.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 
  2. using System.IO;
  3. namespace ProtoBuf
  4. {
  5. /// <summary>
  6. /// Provides addition capability for supporting unexpected fields during
  7. /// protocol-buffer serialization/deserialization. This allows for loss-less
  8. /// round-trip/merge, even when the data is not fully understood.
  9. /// </summary>
  10. public interface IExtension
  11. {
  12. /// <summary>
  13. /// Requests a stream into which any unexpected fields can be persisted.
  14. /// </summary>
  15. /// <returns>A new stream suitable for storing data.</returns>
  16. Stream BeginAppend();
  17. /// <summary>
  18. /// Indicates that all unexpected fields have now been stored. The
  19. /// implementing class is responsible for closing the stream. If
  20. /// "commit" is not true the data may be discarded.
  21. /// </summary>
  22. /// <param name="stream">The stream originally obtained by BeginAppend.</param>
  23. /// <param name="commit">True if the append operation completed successfully.</param>
  24. void EndAppend(Stream stream, bool commit);
  25. /// <summary>
  26. /// Requests a stream of the unexpected fields previously stored.
  27. /// </summary>
  28. /// <returns>A prepared stream of the unexpected fields.</returns>
  29. Stream BeginQuery();
  30. /// <summary>
  31. /// Indicates that all unexpected fields have now been read. The
  32. /// implementing class is responsible for closing the stream.
  33. /// </summary>
  34. /// <param name="stream">The stream originally obtained by BeginQuery.</param>
  35. void EndQuery(Stream stream);
  36. /// <summary>
  37. /// Requests the length of the raw binary stream; this is used
  38. /// when serializing sub-entities to indicate the expected size.
  39. /// </summary>
  40. /// <returns>The length of the binary stream representing unexpected data.</returns>
  41. int GetLength();
  42. }
  43. }