using System;

namespace Edge.Core.Parser
{
    /// <summary>
    /// The message parsing is defined as 2 direction convert, 
    /// we say the 'forward' direction convert is from an unreadable format data to a readable static type object, like the bytes to object, this is called Deserialize.
    /// vice versa, the 'backward' direction convert is covert a readable staic type object to an unreadable format data, like covert the object to bytes, this is called Serialize. 
    /// </summary>
    /// <typeparam name="TRaw">Type for unreadable format data</typeparam>
    /// <typeparam name="TMessage">Type for readable object</typeparam>
    public interface IMessageParser<TRaw, TMessage> //where TTemplate : MessageTemplateBase
    {
        event EventHandler<ParsingEventArg<TRaw, TMessage>> Deserializing;
        event EventHandler<DeserializeEventArg<TRaw, TMessage>> Deserialized;
        event EventHandler<ParsingEventArg<TMessage, TRaw>> Serializing;
        event EventHandler<ParsingEventArg<TMessage, TRaw>> Serialized;
        event EventHandler<ParsingEventArg<string, TRaw>> FieldSerializing;
        event EventHandler<ParsingEventArg<string, TRaw>> FieldSerialized;
        TMessage Deserialize(TRaw data);
        TRaw Serialize(TMessage message);
    }
}
