private static InstructionArgumentEditorViewModel CreateViewModel() { var reader = new OpCodeDescriptionReader(); IOpCodeDescriptionDefinition data = null; if (File.Exists("OpCodeDescriptions.xml")) { data = reader.Read("OpCodeDescriptions.xml"); } else if (File.Exists(@"C:\git\PapyrusDotNet\Source\PapyrusDotNet.PexInspector\OpCodeDescriptions.xml")) { data = reader.Read(@"C:\git\PapyrusDotNet\Source\PapyrusDotNet.PexInspector\OpCodeDescriptions.xml"); } else { data = reader.Read(@"D:\git\PapyrusDotNet\Source\PapyrusDotNet.PexInspector\OpCodeDescriptions.xml"); } var desc = data.GetDesc(PapyrusOpCodes.Cast); if (desc.Arguments == null || desc.Arguments.Count == 0) { desc.Arguments = new List <OpCodeArgumentDescription>(); var fallbackDesc = PapyrusInstructionOpCodeDescription.FromOpCode(desc.OpCode); for (var i = 0; i < fallbackDesc.ArgumentCount; i++) { desc.Arguments.Add(new OpCodeArgumentDescription { Index = i, Alias = "Value" + (i + 1), Ref = OpCodeRef.None, Description = "", ValueType = OpCodeValueTypes.ReferenceOrConstant }); } } return(new InstructionArgumentEditorViewModel(null, null, null, null, null, null, desc)); }
public PapyrusInstructionEditorViewModel(IDialogService dialogService, List <PapyrusAssemblyDefinition> loadedAssemblies, PapyrusAssemblyDefinition loadedAssembly, PapyrusTypeDefinition currentType, PapyrusMethodDefinition currentMethod, PapyrusInstruction instruction = null) { opCodeDescriptionReader = new OpCodeDescriptionReader(); if (File.Exists("OpCodeDescriptions.xml")) { opCodeDescriptionDefinition = opCodeDescriptionReader.Read("OpCodeDescriptions.xml"); } else if (File.Exists( @"C:\git\PapyrusDotNet\Source\PapyrusDotNet.PexInspector\OpCodeDescriptions.xml")) { opCodeDescriptionDefinition = opCodeDescriptionReader.Read( @"C:\git\PapyrusDotNet\Source\PapyrusDotNet.PexInspector\OpCodeDescriptions.xml"); } else { opCodeDescriptionDefinition = opCodeDescriptionReader.Read( @"D:\git\PapyrusDotNet\Source\PapyrusDotNet.PexInspector\OpCodeDescriptions.xml"); } this.dialogService = dialogService; this.loadedAssemblies = loadedAssemblies; this.loadedAssembly = loadedAssembly; this.currentType = currentType; this.currentMethod = currentMethod; this.instruction = instruction; if (instruction == null) { isNewInstruction = true; var defaultOpCode = PapyrusOpCodes.Nop; SelectedOpCodeDescription = new InstructionArgumentEditorViewModel(dialogService, loadedAssemblies, loadedAssembly, currentType, currentMethod, null, opCodeDescriptionDefinition.GetDesc(defaultOpCode)); SelectedOpCode = defaultOpCode; // ArgumentsDescription = defaultOpCode.GetArgumentsDescription(); OperandArgumentsDescription = defaultOpCode.GetOperandArgumentsDescription(); OperandArgumentsVisible = !operandArgumentsDescription.ToLower().Contains("no operand"); OperandArguments = new ObservableCollection <PapyrusVariableReference>(); } else { SelectedOpCode = instruction.OpCode; SelectedOpCodeDescriptionString = instruction.OpCode.GetDescription(); SelectedOpCodeDescription = new InstructionArgumentEditorViewModel(dialogService, loadedAssemblies, loadedAssembly, currentType, currentMethod, instruction, opCodeDescriptionDefinition.GetDesc(instruction.OpCode)); // instruction.OpCode.GetDescription(); // ArgumentsDescription = instruction.OpCode.GetArgumentsDescription(); OperandArgumentsDescription = instruction.OpCode.GetOperandArgumentsDescription(); OperandArgumentsVisible = !operandArgumentsDescription.ToLower().Contains("no operand"); OperandArguments = new ObservableCollection <PapyrusVariableReference>(instruction.OperandArguments); } AvailableOpCodes = new ObservableCollection <PapyrusOpCodes>(Enum.GetValues(typeof(PapyrusOpCodes)).Cast <PapyrusOpCodes>()); AddOperandArgumentCommand = new RelayCommand(AddOpArg); RemoveOperandArgumentCommand = new RelayCommand(RemoveOpArg, CanEdit); EditOperandArgumentCommand = new RelayCommand(EditOpArg, CanEdit); }