public ExceptionHandlerVM(TypeSigCreatorOptions typeSigCreatorOptions, ExceptionHandlerOptions options) { this.typeSigCreatorOptions = typeSigCreatorOptions.Clone("Create an Exception Catch Type"); this.typeSigCreatorOptions.IsLocal = false; this.typeSigCreatorOptions.NullTypeSigAllowed = true; this.origOptions = options; this.handlerTypeVM = new EnumListVM(exceptionHandlerTypeList); this.tryStartVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction }; this.tryEndVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction }; this.filterStartVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction }; this.handlerStartVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction }; this.handlerEndVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction }; Reinitialize(); }
string VerifyInstruction(ListVM<InstructionVM> list) { var item = list.SelectedItem; var instr = item as InstructionVM; if (item != null && instr == null) return "Only instructions can be selected"; if (instr != null && instr.Index == -1) return "Instruction has been removed"; return string.Empty; }
bool HasListError(ListVM<InstructionVM> list) { return !string.IsNullOrEmpty(VerifyInstruction(list)) ; }