public PropertyOptionsVM(PropertyDefOptions options, ModuleDef ownerModule, ILanguageManager languageManager, TypeDef ownerType) { this.ownerModule = ownerModule; this.origOptions = options; var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, languageManager) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = true, OwnerType = ownerType, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) { typeSigCreatorOptions.CanAddGenericTypeVar = false; } var methodSigCreatorOptions = new MethodSigCreatorOptions(typeSigCreatorOptions); methodSigCreatorOptions.IsPropertySig = true; this.methodSigCreator = new MethodSigCreatorVM(methodSigCreatorOptions); this.methodSigCreator.PropertyChanged += methodSigCreator_PropertyChanged; this.methodSigCreator.ParametersCreateTypeSigArray.PropertyChanged += methodSigCreator_PropertyChanged; this.methodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.CanAddFnPtr = false; this.getMethodsVM = new MethodDefsVM(ownerModule, languageManager); this.setMethodsVM = new MethodDefsVM(ownerModule, languageManager); this.otherMethodsVM = new MethodDefsVM(ownerModule, languageManager); this.customAttributesVM = new CustomAttributesVM(ownerModule, languageManager); this.constantVM = new ConstantVM(ownerModule, options.Constant == null ? null : options.Constant.Value, dnSpy_AsmEditor_Resources.Property_DefaultValue); this.constantVM.PropertyChanged += constantVM_PropertyChanged; ConstantVM.IsEnabled = HasDefault; Reinitialize(); }
void EditMethodSig(InstructionOperandVM opvm) { var creator = new CreateMethodPropertySig(Window.GetWindow(listBox)); var opts = new MethodSigCreatorOptions(cilBodyVM.TypeSigCreatorOptions.Clone(dnSpy_AsmEditor_Resources.CreateMethodSig)); opts.CanHaveSentinel = true; var sig = (MethodSig)creator.Create(opts, opvm.Other as MethodSig); if (sig != null) { opvm.Other = sig; } }
public MethodOptionsVM(MethodDefOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod) { this.ownerModule = ownerModule; var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = ownerMethod == null || ownerMethod.GenericParameters.Count > 0, OwnerType = ownerType, OwnerMethod = ownerMethod, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) { typeSigCreatorOptions.CanAddGenericTypeVar = false; } var methodSigCreatorOptions = new MethodSigCreatorOptions(typeSigCreatorOptions); methodSigCreatorOptions.IsPropertySig = false; MethodSigCreator = new MethodSigCreatorVM(methodSigCreatorOptions); MethodSigCreator.PropertyChanged += methodSigCreator_PropertyChanged; MethodSigCreator.ParametersCreateTypeSigArray.PropertyChanged += methodSigCreator_PropertyChanged; MethodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.ShowTypeFullName = true; MethodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.CanAddFnPtr = false; CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService, ownerType, ownerMethod); DeclSecuritiesVM = new DeclSecuritiesVM(ownerModule, decompilerService, ownerType, ownerMethod); ParamDefsVM = new ParamDefsVM(ownerModule, decompilerService, ownerType, ownerMethod); GenericParamsVM = new GenericParamsVM(ownerModule, decompilerService, ownerType, ownerMethod); MethodOverridesVM = new MethodOverridesVM(ownerModule, decompilerService, ownerType, ownerMethod); origOptions = options; ImplMapVM = new ImplMapVM(ownerModule); ImplMapVM.PropertyChanged += implMapVM_PropertyChanged; ImplMapVM.IsEnabled = PinvokeImpl; Reinitialize(); }
public MethodBaseSig Create(MethodSigCreatorOptions options, MethodBaseSig origSig) { var data = new MethodSigCreatorVM(options); if (origSig is MethodSig) { data.MethodSig = (MethodSig)origSig; } else if (origSig is PropertySig) { data.PropertySig = (PropertySig)origSig; } var win = new MethodSigCreatorDlg(); win.DataContext = data; win.Owner = ownerWindow ?? Application.Current.MainWindow; if (win.ShowDialog() != true) { return(null); } return(data.MethodBaseSig); }