1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System.IO;
- namespace fis.Vid
- {
- public class VinnoApplication
- {
- /// <summary>
- /// Gets the application's ID
- /// </summary>
- public string ApplicationId { get; }
- /// <summary>
- /// Gets the OriginalId of the applciation.
- /// </summary>
- public string ApplicationOriginalId { get; }
- /// <summary>
- /// Gets the application's name.
- /// </summary>
- public string ApplicationName { get; }
- /// <summary>
- /// Gets the applciation's category name.
- /// </summary>
- public string ApplicationCategoryName { get; }
- /// <summary>
- /// Gets if is user defined.
- /// </summary>
- 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;
- }
- }
- }
|