Exemple #1
0
        public PropertyOptionsVM(PropertyDefOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            this.origOptions = options;

            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) {
                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, language);
            this.setMethodsVM = new MethodDefsVM(ownerModule, language);
            this.otherMethodsVM = new MethodDefsVM(ownerModule, language);
            this.customAttributesVM = new CustomAttributesVM(ownerModule, language);
            this.constantVM = new ConstantVM(ownerModule, options.Constant == null ? null : options.Constant.Value, "Default value for this property");
            this.constantVM.PropertyChanged += constantVM_PropertyChanged;

            ConstantVM.IsEnabled = HasDefault;
            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 ?? MainWindow.Instance;
            if (win.ShowDialog() != true)
                return null;

            return data.MethodBaseSig;
        }
Exemple #3
0
 public MethodSigCreatorVM(MethodSigCreatorOptions options)
 {
     this.options = options.Clone();
     this.title   = options.TypeSigCreatorOptions.Title;
     this.parametersCreateTypeSigArray = new CreateTypeSigArrayVM(options.TypeSigCreatorOptions.Clone(null), null);
     this.ParametersCreateTypeSigArray.TypeSigCollection.CollectionChanged += (s, e) => OnPropertyChanged("SignatureFullName");
     this.sentinelCreateTypeSigArray = new CreateTypeSigArrayVM(options.TypeSigCreatorOptions.Clone(null), null);
     this.SentinelCreateTypeSigArray.TypeSigCollection.CollectionChanged += (s, e) => OnPropertyChanged("SignatureFullName");
     this.sentinelCreateTypeSigArray.IsEnabled = CanHaveSentinel;
     this.genericParameterCount = new UInt32VM(0, a => {
         HasErrorUpdated();
         OnPropertyChanged("SignatureFullName");
         if (GenericParameterCount != null && !GenericParameterCount.HasError)
         {
             IsGeneric = GenericParameterCount.Value != 0;
         }
     })
     {
         Min = ModelUtils.COMPRESSED_UINT32_MIN,
         Max = ModelUtils.COMPRESSED_UINT32_MAX,
     };
     this.methodCallingConvVM = new EnumListVM(methodCallingConvList, (a, b) => {
         if (!IsMethodSig)
         {
             throw new InvalidOperationException();
         }
         CallingConvention = (CallingConvention & ~dnlib.DotNet.CallingConvention.Mask) |
                             (dnlib.DotNet.CallingConvention)(MethodCallingConv) MethodCallingConv.SelectedItem;
     });
     if (!CanHaveSentinel)
     {
         MethodCallingConv.Items.RemoveAt(MethodCallingConv.GetIndex(DnlibDialogs.MethodCallingConv.VarArg));
         MethodCallingConv.Items.RemoveAt(MethodCallingConv.GetIndex(DnlibDialogs.MethodCallingConv.NativeVarArg));
     }
     if (IsMethodSig)
     {
         MethodCallingConv.SelectedItem = DnlibDialogs.MethodCallingConv.Default;
     }
     else
     {
         CallingConvention = (CallingConvention & ~dnlib.DotNet.CallingConvention.Mask) | dnlib.DotNet.CallingConvention.Property;
     }
     ReturnType = options.TypeSigCreatorOptions.OwnerModule.CorLibTypes.Void;
 }
Exemple #4
0
        public MemberRefVM(MemberRefOptions options, TypeSigCreatorOptions typeSigCreatorOptions, bool isField)
        {
            this.isField = isField;
            this.typeSigCreatorOptions = typeSigCreatorOptions.Clone();
            this.origOptions = options;
            this.customAttributesVM = new CustomAttributesVM(typeSigCreatorOptions.OwnerModule, typeSigCreatorOptions.Language);

            this.typeSigCreatorOptions.CanAddGenericMethodVar = true;
            this.typeSigCreatorOptions.CanAddGenericTypeVar = true;
            this.typeSigCreatorOptions.IsLocal = false;
            this.typeSigCreatorOptions.NullTypeSigAllowed = false;

            this.typeSigCreatorVM = new TypeSigCreatorVM(this.typeSigCreatorOptions.Clone("Create Field TypeSig"));
            TypeSigCreatorVM.PropertyChanged += (s, e) => HasErrorUpdated();

            var mopts = new MethodSigCreatorOptions(this.typeSigCreatorOptions.Clone());
            mopts.CanHaveSentinel = true;
            this.methodSigCreatorVM = new MethodSigCreatorVM(mopts);
            MethodSigCreatorVM.PropertyChanged += (s, e) => HasErrorUpdated();

            Reinitialize();
        }
Exemple #5
0
        public MemberRefVM(MemberRefOptions options, TypeSigCreatorOptions typeSigCreatorOptions, bool isField)
        {
            this.isField = isField;
            this.typeSigCreatorOptions = typeSigCreatorOptions.Clone();
            this.origOptions           = options;
            this.customAttributesVM    = new CustomAttributesVM(typeSigCreatorOptions.OwnerModule, typeSigCreatorOptions.Language);

            this.typeSigCreatorOptions.CanAddGenericMethodVar = true;
            this.typeSigCreatorOptions.CanAddGenericTypeVar   = true;
            this.typeSigCreatorOptions.IsLocal            = false;
            this.typeSigCreatorOptions.NullTypeSigAllowed = false;

            this.typeSigCreatorVM             = new TypeSigCreatorVM(this.typeSigCreatorOptions.Clone("Create Field TypeSig"));
            TypeSigCreatorVM.PropertyChanged += (s, e) => HasErrorUpdated();

            var mopts = new MethodSigCreatorOptions(this.typeSigCreatorOptions.Clone());

            mopts.CanHaveSentinel               = true;
            this.methodSigCreatorVM             = new MethodSigCreatorVM(mopts);
            MethodSigCreatorVM.PropertyChanged += (s, e) => HasErrorUpdated();

            Reinitialize();
        }
Exemple #6
0
        void AddFnPtrSig()
        {
            if (createMethodPropertySig == null)
            {
                throw new InvalidOperationException();
            }

            var createOptions = new MethodSigCreatorOptions(options.Clone("Create FnPtr Method Signature"));

            createOptions.IsPropertySig   = false;
            createOptions.CanHaveSentinel = true;

            var fnPtrSig = TypeSig as FnPtrSig;
            var msig     = fnPtrSig == null ? null : fnPtrSig.MethodSig;
            var sig      = createMethodPropertySig.Create(createOptions, msig);

            if (sig == null)
            {
                return;
            }

            TypeSig = new FnPtrSig(sig);
        }
Exemple #7
0
        public MethodOptionsVM(MethodDefOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) {
                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, language, ownerType, ownerMethod);
            this.declSecuritiesVM = new DeclSecuritiesVM(ownerModule, language, ownerType, ownerMethod);
            this.paramDefsVM = new ParamDefsVM(ownerModule, language, ownerType, ownerMethod);
            this.genericParamsVM = new GenericParamsVM(ownerModule, language, ownerType, ownerMethod);
            this.methodOverridesVM = new MethodOverridesVM(ownerModule, language, ownerType, ownerMethod);

            this.origOptions = options;

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

            ImplMapVM.IsEnabled = PinvokeImpl;
            Reinitialize();
        }
Exemple #8
0
        void AddFnPtrSig()
        {
            if (createMethodPropertySig == null)
                throw new InvalidOperationException();

            var createOptions = new MethodSigCreatorOptions(options.Clone("Create FnPtr Method Signature"));
            createOptions.IsPropertySig = false;
            createOptions.CanHaveSentinel = true;

            var fnPtrSig = TypeSig as FnPtrSig;
            var msig = fnPtrSig == null ? null : fnPtrSig.MethodSig;
            var sig = createMethodPropertySig.Create(createOptions, msig);
            if (sig == null)
                return;

            TypeSig = new FnPtrSig(sig);
        }