示例#1
0
        public MethodOptionsVM(MethodDefOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerManager)
            {
                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;
            this.MethodSigCreator = new MethodSigCreatorVM(methodSigCreatorOptions);
            this.MethodSigCreator.PropertyChanged += methodSigCreator_PropertyChanged;
            this.MethodSigCreator.ParametersCreateTypeSigArray.PropertyChanged += methodSigCreator_PropertyChanged;
            this.MethodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.ShowTypeFullName = true;
            this.MethodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.CanAddFnPtr      = false;

            this.CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerManager, ownerType, ownerMethod);
            this.DeclSecuritiesVM   = new DeclSecuritiesVM(ownerModule, decompilerManager, ownerType, ownerMethod);
            this.ParamDefsVM        = new ParamDefsVM(ownerModule, decompilerManager, ownerType, ownerMethod);
            this.GenericParamsVM    = new GenericParamsVM(ownerModule, decompilerManager, ownerType, ownerMethod);
            this.MethodOverridesVM  = new MethodOverridesVM(ownerModule, decompilerManager, ownerType, ownerMethod);

            this.origOptions = options;

            this.ImplMapVM             = new ImplMapVM(ownerModule);
            ImplMapVM.PropertyChanged += implMapVM_PropertyChanged;

            ImplMapVM.IsEnabled = PinvokeImpl;
            Reinitialize();
        }
示例#2
0
        public FieldOptionsVM(FieldDefOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerManager)
            {
                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, decompilerManager);
            this.origOptions        = options;

            this.ConstantVM                = new ConstantVM(ownerModule, options.Constant?.Value, dnSpy_AsmEditor_Resources.Field_DefaultValueInfo);
            ConstantVM.PropertyChanged    += constantVM_PropertyChanged;
            this.MarshalTypeVM             = new MarshalTypeVM(ownerModule, decompilerManager, 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();
        }
示例#3
0
        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();
        }
示例#4
0
        public CilBodyVM(CilBodyOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod, bool initialize)
        {
            this.OwnerModule = ownerModule;
            this.ownerMethod = ownerMethod;
            this.origOptions = options;

            TypeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerManager)
            {
                CanAddGenericTypeVar   = ownerType.HasGenericParameters,
                CanAddGenericMethodVar = ownerMethod.MethodSig.GetGenParamCount() > 0,
                OwnerType   = ownerType,
                OwnerMethod = ownerMethod,
            };

            this.LocalsListVM                                  = new LocalsIndexObservableCollection(this, () => new LocalVM(TypeSigCreatorOptions, new LocalOptions(new Local(ownerModule.CorLibTypes.Int32))));
            this.InstructionsListVM                            = new IndexObservableCollection <InstructionVM>(() => CreateInstructionVM());
            this.ExceptionHandlersListVM                       = new IndexObservableCollection <ExceptionHandlerVM>(() => new ExceptionHandlerVM(TypeSigCreatorOptions, new ExceptionHandlerOptions()));
            this.LocalsListVM.UpdateIndexesDelegate            = LocalsUpdateIndexes;
            this.InstructionsListVM.UpdateIndexesDelegate      = InstructionsUpdateIndexes;
            this.ExceptionHandlersListVM.UpdateIndexesDelegate = ExceptionHandlersUpdateIndexes;
            this.InstructionsListVM.CollectionChanged         += InstructionsListVM_CollectionChanged;
            this.LocalsListVM.CollectionChanged               += LocalsListVM_CollectionChanged;
            this.ExceptionHandlersListVM.CollectionChanged    += ExceptionHandlersListVM_CollectionChanged;
            this.MaxStack         = new UInt16VM(a => CallHasErrorUpdated());
            this.LocalVarSigTok   = new UInt32VM(a => CallHasErrorUpdated());
            this.HeaderSize       = new ByteVM(a => CallHasErrorUpdated());
            this.HeaderRVA        = new UInt32VM(a => CallHasErrorUpdated());
            this.HeaderFileOffset = new UInt64VM(a => CallHasErrorUpdated());
            this.RVA        = new UInt32VM(a => CallHasErrorUpdated());
            this.FileOffset = new UInt64VM(a => CallHasErrorUpdated());

            if (initialize)
            {
                Reinitialize();
            }
        }
示例#5
0
        public object Create(ModuleDef ownerModule, object value, ConstantType[] validConstants, bool allowNullString, bool arraysCanBeNull, TypeSigCreatorOptions options, out object resultNoSpecialNull, out bool canceled)
        {
            var data = new ConstantTypeVM(ownerModule, value, validConstants ?? DefaultConstants, true, true, options);
            var win  = new ConstantTypeDlg();

            win.DataContext = data;
            win.Owner       = ownerWindow ?? MainWindow.Instance;
            if (win.ShowDialog() != true)
            {
                canceled            = true;
                resultNoSpecialNull = null;
                return(null);
            }

            canceled            = false;
            resultNoSpecialNull = data.ValueNoSpecialNull;
            return(data.Value);
        }
示例#6
0
 public TypeDefOrRefVM(ITypeDefOrRef?value, Action <DataFieldVM> onUpdated, TypeSigCreatorOptions options)
     : base(value !, onUpdated, options)
示例#7
0
 public TypeDefOrRefVM(Action <DataFieldVM> onUpdated, TypeSigCreatorOptions options)
     : this(null, onUpdated, options)
 {
 }