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; } this.TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions); this.TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged; this.CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService, ownerType, null); this.DeclSecuritiesVM = new DeclSecuritiesVM(ownerModule, decompilerService, ownerType, null); this.GenericParamsVM = new GenericParamsVM(ownerModule, decompilerService, ownerType, null); this.InterfaceImplsVM = new TypeDefOrRefAndCAsVM <InterfaceImpl>(dnSpy_AsmEditor_Resources.EditInterfaceImpl, dnSpy_AsmEditor_Resources.CreateInterfaceImpl, ownerModule, decompilerService, ownerType, null); this.origOptions = options; this.IsNestedType = (options.Attributes & TypeAttributes.VisibilityMask) > TypeAttributes.Public; this.TypeKind = new EnumListVM(typeKindList, (a, b) => OnTypeKindChanged()); this.TypeLayout = new EnumListVM(typeLayoutList, (a, b) => InitializeTypeKind()); this.TypeSemantics = new EnumListVM(typeSemanticsList, (a, b) => InitializeTypeKind()); this.PackingSize = new NullableUInt16VM(a => HasErrorUpdated()); this.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(); this.TypeSigCreator.CanAddFnPtr = false; Reinitialize(); }
public GenericParamVM(GenericParamOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod) { this.ownerModule = ownerModule; this.origOptions = options; this.number = new UInt16VM(a => { OnPropertyChanged("FullName"); HasErrorUpdated(); }); this.typeDefOrRefAndCAsVM = new TypeDefOrRefAndCAsVM<GenericParamConstraint>("Edit Generic Parameter Constraint", "Create Generic Parameter Constraint", ownerModule, language, ownerType, ownerMethod); this.customAttributesVM = new CustomAttributesVM(ownerModule, language); this.gpVarianceVM = new EnumListVM(EnumVM.Create(typeof(GPVariance))); var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = false, OwnerType = ownerType, OwnerMethod = ownerMethod, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) typeSigCreatorOptions.CanAddGenericTypeVar = false; if (ownerMethod != null && ownerMethod.GenericParameters.Count > 0) typeSigCreatorOptions.CanAddGenericMethodVar = true; this.typeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions); 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 GenericParamVM(GenericParamOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod) { this.ownerModule = ownerModule; origOptions = options; Number = new UInt16VM(a => { OnPropertyChanged(nameof(FullName)); HasErrorUpdated(); }); TypeDefOrRefAndCAsVM = new TypeDefOrRefAndCAsVM<GenericParamConstraint>(dnSpy_AsmEditor_Resources.EditGenericParameterConstraint, dnSpy_AsmEditor_Resources.CreateGenericParameterConstraint, ownerModule, decompilerService, ownerType, ownerMethod); CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService); GPVarianceVM = new EnumListVM(EnumVM.Create(typeof(GPVariance))); var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService) { IsLocal = false, CanAddGenericTypeVar = true, CanAddGenericMethodVar = false, OwnerType = ownerType, OwnerMethod = ownerMethod, }; if (ownerType != null && ownerType.GenericParameters.Count == 0) typeSigCreatorOptions.CanAddGenericTypeVar = false; if (ownerMethod != null && ownerMethod.GenericParameters.Count > 0) typeSigCreatorOptions.CanAddGenericMethodVar = true; TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions); Reinitialize(); }