summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Core/Messaging/IStreamSerializingDataBag.cs
blob: cc82d6a0b590bdf8d1002acfd66368fbe14e2c8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//-----------------------------------------------------------------------
// <copyright file="IStreamSerializingDataBag.cs" company="Outercurve Foundation">
//     Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.Messaging {
	using System;
	using System.Diagnostics.Contracts;
	using System.IO;

	/// <summary>
	/// An interface implemented by <see cref="DataBag"/>-derived types that support binary serialization.
	/// </summary>
	[ContractClass(typeof(IStreamSerializingDataBaContract))]
	internal interface IStreamSerializingDataBag {
		/// <summary>
		/// Serializes the instance to the specified stream.
		/// </summary>
		/// <param name="stream">The stream.</param>
		void Serialize(Stream stream);

		/// <summary>
		/// Initializes the fields on this instance from the specified stream.
		/// </summary>
		/// <param name="stream">The stream.</param>
		void Deserialize(Stream stream);
	}

	/// <summary>
	/// Code Contract for the <see cref="IStreamSerializingDataBag"/> interface.
	/// </summary>
	[ContractClassFor(typeof(IStreamSerializingDataBag))]
	internal abstract class IStreamSerializingDataBaContract : IStreamSerializingDataBag {
		/// <summary>
		/// Serializes the instance to the specified stream.
		/// </summary>
		/// <param name="stream">The stream.</param>
		void IStreamSerializingDataBag.Serialize(Stream stream) {
			Contract.Requires(stream != null);
			Contract.Requires(stream.CanWrite);
			throw new NotImplementedException();
		}

		/// <summary>
		/// Initializes the fields on this instance from the specified stream.
		/// </summary>
		/// <param name="stream">The stream.</param>
		void IStreamSerializingDataBag.Deserialize(Stream stream) {
			Contract.Requires(stream != null);
			Contract.Requires(stream.CanRead);
			throw new NotImplementedException();
		}
	}
}