private void OpenMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (asm != null && asm.Strings.Any(s => s.IsDirty))
            {
                if (MessageBox.Show("You have unsaved changes. Really open a new file?", Title, MessageBoxButton.YesNo) == MessageBoxResult.No)
                    return;
            }

            var ofd = new OpenFileDialog();

            if (ofd.ShowDialog() != true)
                return;

            try
            {
                using (var f = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read))
                {
                    DataContext = asm = CompiledAssembly.Load(f);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Could not open file: {ex}");
            }
        }
        private void OpenMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (asm != null && asm.Strings.Any(s => s.IsDirty))
            {
                if (MessageBox.Show("You have unsaved changes. Really open a new file?", Title, MessageBoxButton.YesNo) == MessageBoxResult.No)
                {
                    return;
                }
            }

            var ofd = new OpenFileDialog();

            if (ofd.ShowDialog() != true)
            {
                return;
            }

            try
            {
                using (var f = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read))
                {
                    DataContext = asm = CompiledAssembly.Load(f);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Could not open file: {ex}");
            }
        }
        public static CompiledAssembly Load(Stream stream)
        {
            var asm = new CompiledAssembly(AssemblyDefinition.ReadAssembly(stream));

            foreach (var module in asm.Assembly.Modules)
            {
                foreach (var type in module.Types)
                {
                    foreach (var method in type.Methods.Where(m => m.Body != null))
                    {
                        foreach (var inst in method.Body.Instructions)
                        {
                            if (inst.OpCode == OpCodes.Ldstr)
                            {
                                Debug.WriteLine($"{type.Name}.{method.Name}: {inst.Operand}");
                                asm.Strings.Add(new CompiledString(method, inst));
                            }
                        }
                    }
                }
            }

            return asm;
        }
        public static CompiledAssembly Load(Stream stream)
        {
            var asm = new CompiledAssembly(AssemblyDefinition.ReadAssembly(stream));

            foreach (var module in asm.Assembly.Modules)
            {
                foreach (var type in module.Types)
                {
                    foreach (var method in type.Methods.Where(m => m.Body != null))
                    {
                        foreach (var inst in method.Body.Instructions)
                        {
                            if (inst.OpCode == OpCodes.Ldstr)
                            {
                                Debug.WriteLine($"{type.Name}.{method.Name}: {inst.Operand}");
                                asm.Strings.Add(new CompiledString(method, inst));
                            }
                        }
                    }
                }
            }

            return(asm);
        }