Пример #1
0
        /// <summary>
        /// Change type and compare
        /// </summary>
        /// <param name="binary">Binary dump</param>
        /// <param name="expectedType">Expected type</param>
        private void AssertSwitch(byte[] binary, string expectedType)
        {
            var dump     = new RamDump(binary);
            var switcher = RamTypeSwitcherFactory.CreateForSource(dump.Type);
            var changed  = switcher.SwitchType(dump);

            Assert.AreEqual(expectedType, changed.Type.Name);

            Assert.AreEqual(2, changed.ActualCrc.Length);
            Assert.AreNotEqual(dump.ActualCrc[0], changed.ActualCrc[0]);
            Assert.AreNotEqual(dump.ActualCrc[1], changed.ActualCrc[1]);
        }
Пример #2
0
        /// <summary>
        /// Write conversion result
        /// </summary>
        public void OnOutputFileSelected(object sender, EventArgs e)
        {
            if (e is PathEventArgs)
            {
                try {
                    IRamTypeSwitcher switcher = RamTypeSwitcherFactory.CreateForSource(this._dump.Type);
                    var switched = switcher.SwitchType(this._dump);
                    File.WriteAllBytes(e.ToString(), switched.Bytes);
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                MessageBox.Show("Successfully converted!", "Success", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }