public EventOptionsVM(EventDefOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType) { this.ownerModule = ownerModule; var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = true, OwnerType = ownerType, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) { typeSigCreatorOptions.CanAddGenericTypeVar = false; } TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions); TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged; CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService); OtherMethodsVM = new MethodDefsVM(ownerModule, decompilerService); origOptions = options; TypeSigCreator.CanAddFnPtr = false; Reinitialize(); }
public EventOptionsVM(EventDefOptions options, ModuleDef ownerModule, ILanguageManager languageManager, TypeDef ownerType) { this.ownerModule = ownerModule; var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, languageManager) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = true, OwnerType = ownerType, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) { typeSigCreatorOptions.CanAddGenericTypeVar = false; } this.typeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions); this.typeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged; this.customAttributesVM = new CustomAttributesVM(ownerModule, languageManager); this.otherMethodsVM = new MethodDefsVM(ownerModule, languageManager); this.origOptions = options; this.typeSigCreator.CanAddFnPtr = false; Reinitialize(); }
public TypeOptionsVM(TypeDefOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType) { this.ownerModule = ownerModule; var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = false, OwnerType = ownerType, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) { typeSigCreatorOptions.CanAddGenericTypeVar = false; } TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions); TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged; CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService, ownerType, null); DeclSecuritiesVM = new DeclSecuritiesVM(ownerModule, decompilerService, ownerType, null); GenericParamsVM = new GenericParamsVM(ownerModule, decompilerService, ownerType, null); InterfaceImplsVM = new TypeDefOrRefAndCAsVM <InterfaceImpl>(dnSpy_AsmEditor_Resources.EditInterfaceImpl, dnSpy_AsmEditor_Resources.CreateInterfaceImpl, ownerModule, decompilerService, ownerType, null); origOptions = options; IsNestedType = (options.Attributes & TypeAttributes.VisibilityMask) > TypeAttributes.Public; TypeKind = new EnumListVM(typeKindList, (a, b) => OnTypeKindChanged()); TypeLayout = new EnumListVM(typeLayoutList, (a, b) => InitializeTypeKind()); TypeSemantics = new EnumListVM(typeSemanticsList, (a, b) => InitializeTypeKind()); PackingSize = new NullableUInt16VM(a => HasErrorUpdated()); ClassSize = new NullableUInt32VM(a => HasErrorUpdated()); Types.TypeVisibility start, end; if (!IsNestedType) { start = Types.TypeVisibility.NotPublic; end = Types.TypeVisibility.Public; } else { start = Types.TypeVisibility.NestedPublic; end = Types.TypeVisibility.NestedFamORAssem; } for (var t = Types.TypeVisibility.NotPublic; t <= Types.TypeVisibility.NestedFamORAssem; t++) { if (t < start || t > end) { TypeVisibility.Items.RemoveAt(TypeVisibility.GetIndex(t)); } } InitializeTypeKind(); TypeSigCreator.CanAddFnPtr = false; Reinitialize(); }
public TypeSig Create(TypeSigCreatorOptions options, TypeSig typeSig, out bool canceled) { var data = new TypeSigCreatorVM(options, typeSig); data.TypeSig = typeSig; var win = new TypeSigCreatorDlg(); win.DataContext = data; win.Owner = ownerWindow ?? MainWindow.Instance; if (win.ShowDialog() != true) { canceled = true; return(null); } canceled = false; return(data.TypeSig); }
public FieldOptionsVM(FieldDefOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType) { this.ownerModule = ownerModule; var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = false, OwnerType = ownerType, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) { typeSigCreatorOptions.CanAddGenericTypeVar = false; } TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions); TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged; CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService); origOptions = options; ConstantVM = new ConstantVM(ownerModule, options.Constant?.Value, dnSpy_AsmEditor_Resources.Field_DefaultValueInfo); ConstantVM.PropertyChanged += constantVM_PropertyChanged; MarshalTypeVM = new MarshalTypeVM(ownerModule, decompilerService, ownerType, null); MarshalTypeVM.PropertyChanged += marshalTypeVM_PropertyChanged; FieldOffset = new NullableUInt32VM(a => HasErrorUpdated()); InitialValue = new HexStringVM(a => HasErrorUpdated()); RVA = new UInt32VM(a => HasErrorUpdated()); ImplMapVM = new ImplMapVM(ownerModule); ImplMapVM.PropertyChanged += implMapVM_PropertyChanged; TypeSigCreator.CanAddFnPtr = false; ConstantVM.IsEnabled = HasDefault; MarshalTypeVM.IsEnabled = HasFieldMarshal; ImplMapVM.IsEnabled = PinvokeImpl; Reinitialize(); }
public FieldOptionsVM(FieldDefOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType) { this.ownerModule = ownerModule; var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = false, OwnerType = ownerType, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) { typeSigCreatorOptions.CanAddGenericTypeVar = false; } this.typeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions); TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged; this.customAttributesVM = new CustomAttributesVM(ownerModule, language); this.origOptions = options; this.constantVM = new ConstantVM(ownerModule, options.Constant == null ? null : options.Constant.Value, "Default value for this field"); ConstantVM.PropertyChanged += constantVM_PropertyChanged; this.marshalTypeVM = new MarshalTypeVM(ownerModule, language, ownerType, null); MarshalTypeVM.PropertyChanged += marshalTypeVM_PropertyChanged; this.fieldOffset = new NullableUInt32VM(a => HasErrorUpdated()); this.initialValue = new HexStringVM(a => HasErrorUpdated()); this.rva = new UInt32VM(a => HasErrorUpdated()); this.implMapVM = new ImplMapVM(ownerModule); ImplMapVM.PropertyChanged += implMapVM_PropertyChanged; this.typeSigCreator.CanAddFnPtr = false; ConstantVM.IsEnabled = HasDefault; MarshalTypeVM.IsEnabled = HasFieldMarshal; ImplMapVM.IsEnabled = PinvokeImpl; Reinitialize(); }