/// <summary>
        /// Creates a Prg Object from a sequence of bytes
        /// Also sets the parent object for messaging purposes. (Load Progress in a Progress Bar?!)
        /// </summary>
        /// <param name="bytes">Sequencec of bytes</param>
        /// <param name="parent">Parent Object</param>
        public Prg(byte[] bytes, Object parent)
            : base(FileVersionUtilities.GetFileVersion(bytes))
        {
            //Set the parent object
            this.SetParentClass(parent);
            try
            {
                if (FileVersion == FileVersion.Unsupported)
                {
                    throw new Exception($@"Data is corrupted or unsupported. First 100 bytes:
{bytes.GetString(0, Math.Min(100, bytes.Length))}");
                }

                switch (FileVersion)
                {
                case FileVersion.Dos:
                    FromDosFormat(bytes);
                    break;

                case FileVersion.Current:
                    FromCurrentFormat(bytes);
                    break;

                default:
                    throw new NotImplementedException("This version not implemented");
                }
            }
            catch (Exception ex) {
                ExceptionHandler.Show(ex, "public Prg(byte[] bytes, Object parent)", true);
            }
        }
Exemple #2
0
        public Prg(byte[] bytes)
            : base(FileVersionUtilities.GetFileVersion(bytes))
        {
            if (FileVersion == FileVersion.Unsupported)
            {
                throw new Exception($@"Data is corrupted or unsupported. First 100 bytes:
{bytes.GetString(0, Math.Min(100, bytes.Length))}");
            }

            switch (FileVersion)
            {
            case FileVersion.Dos:
                FromDosFormat(bytes);
                break;

            case FileVersion.Current:
                FromCurrentFormat(bytes);
                break;

            default:
                throw new NotImplementedException("This version not implemented");
            }
        }