Esempio n. 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();
        }
Esempio n. 2
0
        public CilBodyVM(CilBodyOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule = ownerModule;
            this.ownerMethod = ownerMethod;
            this.origOptions = options;

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

            this.localsListVM = new IndexObservableCollection<LocalVM>(() => 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());

            Reinitialize();
        }
Esempio n. 3
0
 public CreateTypeSigArrayVM(TypeSigCreatorOptions options, int? requiredCount)
 {
     this.title = options.Title;
     this.typeSigCreator = new TypeSigCreatorVM(options);
     this.RequiredCount = requiredCount;
     this.TypeSigCollection.CollectionChanged += (s, e) => UpdateNumberLeftProperties();
 }
Esempio n. 4
0
        public LocalVM(TypeSigCreatorOptions typeSigCreatorOptions, LocalOptions options)
        {
            this.typeSigCreatorOptions = typeSigCreatorOptions.Clone("Create a Local Type");
            this.typeSigCreatorOptions.IsLocal = true;
            this.typeSigCreatorOptions.NullTypeSigAllowed = false;
            this.origOptions = options;

            Reinitialize();
        }
Esempio n. 5
0
        public TypeSig[] Create(TypeSigCreatorOptions options, int? count, TypeSig[] typeSigs)
        {
            var data = new CreateTypeSigArrayVM(options, count);
            if (typeSigs != null)
                data.TypeSigCollection.AddRange(typeSigs);
            var win = new CreateTypeSigArrayDlg();
            win.DataContext = data;
            win.Owner = ownerWindow ?? MainWindow.Instance;
            if (win.ShowDialog() != true)
                return null;

            return data.TypeSigArray;
        }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
        public ExceptionHandlerVM(TypeSigCreatorOptions typeSigCreatorOptions, ExceptionHandlerOptions options)
        {
            this.typeSigCreatorOptions = typeSigCreatorOptions.Clone("Create an Exception Catch Type");
            this.typeSigCreatorOptions.IsLocal = false;
            this.typeSigCreatorOptions.NullTypeSigAllowed = true;
            this.origOptions = options;
            this.handlerTypeVM = new EnumListVM(exceptionHandlerTypeList);
            this.tryStartVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction };
            this.tryEndVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction };
            this.filterStartVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction };
            this.handlerStartVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction };
            this.handlerEndVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction };

            Reinitialize();
        }
Esempio n. 8
0
        public MethodSpecVM(MethodSpecOptions options, TypeSigCreatorOptions typeSigCreatorOptions)
        {
            this.origOptions = options;
            this.typeSigCreatorOptions = typeSigCreatorOptions;
            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.createTypeSigArrayVM = new CreateTypeSigArrayVM(typeSigCreatorOptions, null);

            Reinitialize();
        }
Esempio n. 9
0
        public TypeSigCreatorVM(TypeSigCreatorOptions options, TypeSig defaultTypeSig = null)
        {
            this.options = options.Clone();
            this.defaultTypeSig = defaultTypeSig;
            this.arrayRank = new UInt32VM(2, a => { });
            this.arraySizes = new UInt32ListDataFieldVM(a => { }) {
                Min = ModelUtils.COMPRESSED_UINT32_MIN,
                Max = ModelUtils.COMPRESSED_UINT32_MAX,
            };
            this.arrayLowerBounds = new Int32ListDataFieldVM(a => { }) {
                Min = ModelUtils.COMPRESSED_INT32_MIN,
                Max = ModelUtils.COMPRESSED_INT32_MAX,
            };
            this.genericVariableNumber = new UInt32VM(0, a => { });

            Reinitialize();
        }
Esempio n. 10
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();
        }
Esempio n. 11
0
        public TypeDefOrRefAndCAVM(TypeDefOrRefAndCAOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.origOptions = options;

            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);
            TypeSigCreator.PropertyChanged += TypeSigCreator_PropertyChanged;
            this.customAttributesVM = new CustomAttributesVM(ownerModule, language);

            Reinitialize();
        }
Esempio n. 12
0
        public EventOptionsVM(EventDefOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) {
                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, language);
            this.otherMethodsVM = new MethodDefsVM(ownerModule, language);

            this.origOptions = options;

            this.typeSigCreator.CanAddFnPtr = false;
            Reinitialize();
        }
Esempio n. 13
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();
        }
Esempio n. 14
0
        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();
        }
Esempio n. 15
0
 public ObjectListDataFieldVM(ModuleDef ownerModule, IList <object> value, Action <DataFieldVM> onUpdated, TypeSigCreatorOptions options)
     : base(onUpdated)
 {
     this.ownerModule = ownerModule;
     if (options != null)
     {
         this.options = options.Clone("Create a Type");
         this.options.NullTypeSigAllowed = true;
     }
     SetValue(value);
 }
Esempio n. 16
0
 public ObjectListDataFieldVM(ModuleDef ownerModule, Action <DataFieldVM> onUpdated, TypeSigCreatorOptions options)
     : this(ownerModule, new object[0], onUpdated, options)
 {
 }
Esempio n. 17
0
 public ConstantTypeVM(ModuleDef ownerModule, object value, ConstantType[] validConstants, bool allowNullString, bool arraysCanBeNull, TypeSigCreatorOptions options = null)
 {
     if (options == null) {
         IList<ConstantType> clist = validConstants;
         if (clist.IndexOf(ConstantType.Type) >= 0 ||
             clist.IndexOf(ConstantType.TypeArray) >= 0 ||
             clist.IndexOf(ConstantType.ObjectArray) >= 0) {
             throw new ArgumentNullException();
         }
     }
     this.arraysCanBeNull = arraysCanBeNull;
     var list = validConstants.Select(a => typeToEnumVM[a]);
     this.constantTypeEnumListVM = new EnumListVM(list, (a, b) => OnConstantChanged());
     this.boolean = new BooleanVM(a => FieldUpdated());
     this.@char = new CharVM(a => FieldUpdated());
     this.@sbyte = new SByteVM(a => FieldUpdated());
     this.@byte = new ByteVM(a => FieldUpdated());
     this.int16 = new Int16VM(a => FieldUpdated());
     this.uint16 = new UInt16VM(a => FieldUpdated());
     this.int32 = new Int32VM(a => FieldUpdated());
     this.uint32 = new UInt32VM(a => FieldUpdated());
     this.int64 = new Int64VM(a => FieldUpdated());
     this.uint64 = new UInt64VM(a => FieldUpdated());
     this.single = new SingleVM(a => FieldUpdated());
     this.@double = new DoubleVM(a => FieldUpdated());
     this.@string = new StringVM(a => FieldUpdated(), allowNullString);
     this.@enum = new EnumDataFieldVM(ownerModule, a => FieldUpdated());
     this.type = new TypeSigVM(a => FieldUpdated(), options);
     this.objectArray = new ObjectListDataFieldVM(ownerModule, a => FieldUpdated(), options);
     this.booleanArray = new BooleanListDataFieldVM(a => FieldUpdated());
     this.charArray = new CharListDataFieldVM(a => FieldUpdated());
     this.sbyteArray = new SByteListDataFieldVM(a => FieldUpdated());
     this.byteArray = new ByteListDataFieldVM(a => FieldUpdated());
     this.int16Array = new Int16ListDataFieldVM(a => FieldUpdated());
     this.uint16Array = new UInt16ListDataFieldVM(a => FieldUpdated());
     this.int32Array = new Int32ListDataFieldVM(a => FieldUpdated());
     this.uint32Array = new UInt32ListDataFieldVM(a => FieldUpdated());
     this.int64Array = new Int64ListDataFieldVM(a => FieldUpdated());
     this.uint64Array = new UInt64ListDataFieldVM(a => FieldUpdated());
     this.singleArray = new SingleListDataFieldVM(a => FieldUpdated());
     this.doubleArray = new DoubleListDataFieldVM(a => FieldUpdated());
     this.stringArray = new StringListDataFieldVM(a => FieldUpdated());
     this.enumArray = new EnumListDataFieldVM(ownerModule, a => FieldUpdated());
     this.typeArray = new TypeSigListDataFieldVM(a => FieldUpdated(), options);
     this.Value = value;
 }
Esempio n. 18
0
 public TypeSigVM(TypeSig value, Action <DataFieldVM> onUpdated, TypeSigCreatorOptions options)
     : base(value, onUpdated, options)
 {
 }
Esempio n. 19
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();
        }
Esempio n. 20
0
        public TypeOptionsVM(TypeDefOptions 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);
            this.typeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

            this.customAttributesVM = new CustomAttributesVM(ownerModule, language, ownerType, null);
            this.declSecuritiesVM = new DeclSecuritiesVM(ownerModule, language, ownerType, null);
            this.genericParamsVM = new GenericParamsVM(ownerModule, language, ownerType, null);
            this.typeDefOrRefAndCAsVM = new TypeDefOrRefAndCAsVM<InterfaceImpl>("Edit Interface Impl", "Create Interface Impl", ownerModule, language, ownerType, null);

            this.origOptions = options;
            this.isNestedType = (options.Attributes & TypeAttributes.VisibilityMask) > TypeAttributes.Public;
            this.typeKindVM = new EnumListVM(typeKindList, (a, b) => OnTypeKindChanged());
            this.typeLayoutVM = new EnumListVM(typeLayoutList, (a, b) => InitializeTypeKind());
            this.typeSemanticsVM = 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();
        }
Esempio n. 21
0
 public CANamedArgumentVM(ModuleDef ownerModule, CANamedArgument namedArg, TypeSigCreatorOptions options)
 {
     this.ownerModule = ownerModule;
     this.originalNamedArg = namedArg.Clone();
     this.constantTypeEnumListVM = new EnumListVM(ConstantTypeVM.CreateEnumArray(validTypes), (a, b) => OnConstantTypeChanged());
     this.namedArgTypeEnumListVM = new EnumListVM(EnumVM.Create(typeof(NamedArgType)), (a, b) => OnNamedArgTypeChanged());
     InitializeFrom(namedArg, options);
     this.modified = false;
 }
Esempio n. 22
0
 public TypeSigListDataFieldVM(Action <DataFieldVM> onUpdated, TypeSigCreatorOptions options)
     : this(new TypeSig[0], onUpdated, options)
 {
 }
Esempio n. 23
0
 protected TypeListDataFieldVMBase(IList <T> value, Action <DataFieldVM> onUpdated, TypeSigCreatorOptions options)
     : base(onUpdated)
 {
     if (options != null)
     {
         this.options = options.Clone("Create a Type");
         this.options.NullTypeSigAllowed = true;
     }
     SetValue(value);
 }
Esempio n. 24
0
 public MethodSigCreatorOptions(TypeSigCreatorOptions typeSigCreatorOptions)
 {
     this.TypeSigCreatorOptions = typeSigCreatorOptions;
 }
Esempio n. 25
0
 static TypeSigCreatorVM CreateTypeSigCreatorVM(ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod, bool allowNullTypeSig, PropertyChangedEventHandler handler)
 {
     var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) {
         IsLocal = false,
         CanAddGenericTypeVar = true,
         CanAddGenericMethodVar = false,
         OwnerType = ownerType,
         OwnerMethod = ownerMethod,
         NullTypeSigAllowed = allowNullTypeSig,
     };
     if (ownerType != null && ownerType.GenericParameters.Count == 0)
         typeSigCreatorOptions.CanAddGenericTypeVar = false;
     if (ownerMethod != null && ownerMethod.GenericParameters.Count > 0)
         typeSigCreatorOptions.CanAddGenericMethodVar = true;
     var typeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
     typeSigCreator.PropertyChanged += handler;
     return typeSigCreator;
 }
Esempio n. 26
0
 public MethodSigCreatorOptions(TypeSigCreatorOptions typeSigCreatorOptions)
 {
     this.TypeSigCreatorOptions = typeSigCreatorOptions;
 }
Esempio n. 27
0
        void InitializeFrom(CANamedArgument namedArg, TypeSigCreatorOptions options)
        {
            if (CAArgumentVM != null)
                CAArgumentVM.PropertyChanged -= caArgumentVM_PropertyChanged;
            caArgumentVM = new CAArgumentVM(ownerModule, namedArg.Argument, options, null);
            OnPropertyChanged("CAArgumentVM");
            CAArgumentVM.PropertyChanged += caArgumentVM_PropertyChanged;

            Name = namedArg.Name;
            IsField = namedArg.IsField;
            ITypeDefOrRef newEnumType;
            ConstantTypeEnumList.SelectedItem = GetConstantType(namedArg.Type, out newEnumType);
            EnumType = newEnumType;
            CAArgumentVM.StorageType = GetType((ConstantType)ConstantTypeEnumList.SelectedItem);
        }
Esempio n. 28
0
 public TypeDefOrRefListDataFieldVM(Action <DataFieldVM> onUpdated, TypeSigCreatorOptions options)
     : this(new ITypeDefOrRef[0], onUpdated, options)
 {
 }
Esempio n. 29
0
 public TypeDefOrRefListDataFieldVM(IList <ITypeDefOrRef> value, Action <DataFieldVM> onUpdated, TypeSigCreatorOptions options)
     : base(value, onUpdated, options)
 {
 }
Esempio n. 30
0
 public TypeSigVM(Action <DataFieldVM> onUpdated, TypeSigCreatorOptions options)
     : this(null, onUpdated, options)
 {
 }
Esempio n. 31
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();
        }
Esempio n. 32
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;
        }