namespace StockSharp.Algo.Storages
{
	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.IO;

	using Ecng.Collections;

	/// <summary>
	/// Ñåðèàëèçàòîð.
	/// </summary>
	public interface IMarketDataSerializer
	{
		/// <summary>
		/// Ñîçäàòü ïóñòóþ ìåòà-èíôîðìàöèþ.
		/// </summary>
		/// <param name="date">Äàòà.</param>
		/// <returns>Ìåòà-èíôîðìàöèÿ î äàííûõ çà îäèí äåíü.</returns>
		IMarketDataMetaInfo CreateMetaInfo(DateTime date);

		/// <summary>
		/// Ïðåîáðàçîâàòü äàííûå â ïîòîê áàéòîâ.
		/// </summary>
		/// <param name="data">Äàííûå.</param>
		/// <param name="metaInfo">Ìåòà-èíôîðìàöèÿ î äàííûõ çà îäèí äåíü.</param>
		/// <returns>Ïîòîê áàéòîâ.</returns>
		byte[] Serialize(IEnumerable data, IMarketDataMetaInfo metaInfo);

		/// <summary>
		/// Çàãðóçèòü äàííûå èç ïîòîêà.
		/// </summary>
		/// <param name="stream">Ïîòîêà.</param>
		/// <param name="metaInfo">Ìåòà-èíôîðìàöèÿ î äàííûõ çà îäèí äåíü.</param>
		/// <returns>Äàííûå.</returns>
		IEnumerableEx Deserialize(Stream stream, IMarketDataMetaInfo metaInfo);
	}

	/// <summary>
	/// Ñåðèàëèçàòîð.
	/// </summary>
	/// <typeparam name="TData">Òèï äàííûõ.</typeparam>
	public interface IMarketDataSerializer<TData> : IMarketDataSerializer
	{
		/// <summary>
		/// Ïðåîáðàçîâàòü äàííûå â ïîòîê áàéòîâ.
		/// </summary>
		/// <param name="data">Äàííûå.</param>
		/// <param name="metaInfo">Ìåòà-èíôîðìàöèÿ î äàííûõ çà îäèí äåíü.</param>
		/// <returns>Ïîòîê áàéò.</returns>
		byte[] Serialize(IEnumerable<TData> data, IMarketDataMetaInfo metaInfo);

		/// <summary>
		/// Çàãðóçèòü äàííûå èç ïîòîêà.
		/// </summary>
		/// <param name="stream">Ïîòîê.</param>
		/// <param name="metaInfo">Ìåòà-èíôîðìàöèÿ î äàííûõ çà îäèí äåíü.</param>
		/// <returns>Äàííûå.</returns>
		new IEnumerableEx<TData> Deserialize(Stream stream, IMarketDataMetaInfo metaInfo);
	}
}