Esempio n. 1
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. 2
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. 3
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. 4
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. 5
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. 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 MarshalTypeVM(ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
 {
     this.nativeTypeVM = new EnumListVM(nativeTypeList, (a, b) => { OnNativeTypeChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(this.NativeType, false);
     this.rawMarshalType_data                = new HexStringVM(a => { HasErrorUpdated(); TypeStringUpdated(); });
     this.fixedSysStringMarshalType_size     = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
     this.safeArrayMarshalType_variantTypeVM = new EnumListVM(variantTypeList, (a, b) => { OnSafeArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.safeArrayMarshalType_userDefinedSubType_typeSigCreator = CreateTypeSigCreatorVM(ownerModule, language, ownerType, ownerMethod, true, safeArrayMarshalType_userDefinedSubType_typeSigCreator_PropertyChanged);
     this.fixedArrayMarshalType_size         = new NullableCompressedUInt32(a => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.fixedArrayMarshalType_nativeTypeVM = new EnumListVM(nativeTypeList, (a, b) => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(FixedArrayMarshalType_NativeType, true);
     this.arrayMarshalType_nativeTypeVM = new EnumListVM(nativeTypeList, (a, b) => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(ArrayMarshalType_NativeType, true);
     this.arrayMarshalType_paramNum = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.arrayMarshalType_numElems = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.arrayMarshalType_flags    = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.customMarshalType_custMarshaler_typeSigCreator = CreateTypeSigCreatorVM(ownerModule, language, ownerType, ownerMethod, true, customMarshalType_custMarshaler_typeSigCreator_PropertyChanged);
     this.interfaceMarshalType_iidParamIndex             = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
 }
Esempio n. 8
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. 9
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. 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 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. 12
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. 13
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. 14
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. 15
0
 public MarshalTypeVM(ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
 {
     this.nativeTypeVM = new EnumListVM(nativeTypeList, (a, b) => { OnNativeTypeChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(this.NativeType, false);
     this.rawMarshalType_data = new HexStringVM(a => { HasErrorUpdated(); TypeStringUpdated(); });
     this.fixedSysStringMarshalType_size = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
     this.safeArrayMarshalType_variantTypeVM = new EnumListVM(variantTypeList, (a, b) => { OnSafeArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.safeArrayMarshalType_userDefinedSubType_typeSigCreator = CreateTypeSigCreatorVM(ownerModule, language, ownerType, ownerMethod, true, safeArrayMarshalType_userDefinedSubType_typeSigCreator_PropertyChanged);
     this.fixedArrayMarshalType_size = new NullableCompressedUInt32(a => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.fixedArrayMarshalType_nativeTypeVM = new EnumListVM(nativeTypeList, (a, b) => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(FixedArrayMarshalType_NativeType, true);
     this.arrayMarshalType_nativeTypeVM = new EnumListVM(nativeTypeList, (a, b) => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(ArrayMarshalType_NativeType, true);
     this.arrayMarshalType_paramNum = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.arrayMarshalType_numElems = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.arrayMarshalType_flags = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.customMarshalType_custMarshaler_typeSigCreator = CreateTypeSigCreatorVM(ownerModule, language, ownerType, ownerMethod, true, customMarshalType_custMarshaler_typeSigCreator_PropertyChanged);
     this.interfaceMarshalType_iidParamIndex = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
 }
Esempio n. 16
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();
        }