using System.IO;
namespace fis.Vid
{
public class VinnoApplication
{
///
/// Gets the application's ID
///
public string ApplicationId { get; }
///
/// Gets the OriginalId of the applciation.
///
public string ApplicationOriginalId { get; }
///
/// Gets the application's name.
///
public string ApplicationName { get; }
///
/// Gets the applciation's category name.
///
public string ApplicationCategoryName { get; }
///
/// Gets if is user defined.
///
public bool IsUserDefined { get; }
public VinnoApplication(string applicationId, string applicationOriginalId, string applicationName, string applicationCategoryName, bool isUserDefined)
{
ApplicationId = applicationId;
ApplicationOriginalId = applicationOriginalId;
ApplicationName = applicationName;
ApplicationCategoryName = applicationCategoryName;
IsUserDefined = isUserDefined;
}
public byte[] ToBytes()
{
byte[] result;
using (var stream = new MemoryStream())
{
var writer = new VinnoStreamWriter(stream);
writer.WriteString(ApplicationId);
writer.WriteString(ApplicationOriginalId);
writer.WriteString(ApplicationName);
writer.WriteString(ApplicationCategoryName);
writer.WriteBool(IsUserDefined);
result = stream.ToArray();
}
return result;
}
public static VinnoApplication FromBytes(byte[] bytes)
{
VinnoApplication result;
using (var stream = new MemoryStream(bytes))
{
stream.Position = 0;
var reader = new VinnoStreamReader(stream);
var applicationId = reader.ReadString();
var applicationOriginalId = reader.ReadString();
var applicationName = reader.ReadString();
var applicationCategoryName = reader.ReadString();
var isUserDefined = reader.ReadBool();
result = new VinnoApplication(applicationId,applicationOriginalId,applicationName,applicationCategoryName,isUserDefined);
}
return result;
}
}
}