Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        public TypeDefOrRefAndCAVM(TypeDefOrRefAndCAOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef?ownerType, MethodDef?ownerMethod)
        {
            origOptions = options;

            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = false,
                OwnerType   = ownerType,
                OwnerMethod = ownerMethod,
            };

            if (ownerType is not null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            if (ownerMethod is not null && ownerMethod.GenericParameters.Count > 0)
            {
                typeSigCreatorOptions.CanAddGenericMethodVar = true;
            }

            TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
            TypeSigCreator.PropertyChanged += TypeSigCreator_PropertyChanged;
            CustomAttributesVM              = new CustomAttributesVM(ownerModule, decompilerService);

            Reinitialize();
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
 void InitializeFrom(DeclSecurityOptions options)
 {
     SecurityActionEnumList.SelectedItem = (SecAc)options.Action;
     CustomAttributesVM.InitializeFrom(options.CustomAttributes);
     SecurityAttributesVM.Collection.Clear();
     SecurityAttributesVM.Collection.AddRange(options.SecurityAttributes.Select(a => new SecurityAttributeVM(a, ownerModule, decompilerManager, ownerType, ownerMethod)));
     V1XMLString = options.V1XMLString;
     DeclSecVerEnumList.SelectedItem = options.V1XMLString == null ? DeclSecVer.V2 : DeclSecVer.V1;
 }
Exemplo n.º 6
0
 void InitializeFrom(GenericParamOptions options)
 {
     Number.Value = options.Number;
     Attributes   = options.Flags;
     Name         = options.Name;
     GPVarianceVM.SelectedItem = (GPVariance)((int)(options.Flags & GenericParamAttributes.VarianceMask) >> 0);
     TypeSigCreator.TypeSig    = options.Kind.ToTypeSig();
     TypeDefOrRefAndCAsVM.InitializeFrom(options.GenericParamConstraints);
     CustomAttributesVM.InitializeFrom(options.CustomAttributes);
 }
Exemplo n.º 7
0
        public MethodSpecVM(MethodSpecOptions options, TypeSigCreatorOptions typeSigCreatorOptions)
        {
            origOptions = options;
            this.typeSigCreatorOptions = typeSigCreatorOptions;
            CustomAttributesVM         = new CustomAttributesVM(typeSigCreatorOptions.OwnerModule, typeSigCreatorOptions.DecompilerService);

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

            CreateTypeSigArrayVM = new CreateTypeSigArrayVM(typeSigCreatorOptions, null);

            Reinitialize();
        }
Exemplo n.º 8
0
        public ParamDefVM(ParamDefOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule               = ownerModule;
            this.origOptions               = options;
            this.Sequence                  = new UInt16VM(a => { OnPropertyChanged(nameof(FullName)); HasErrorUpdated(); });
            this.CustomAttributesVM        = new CustomAttributesVM(ownerModule, decompilerService);
            this.ConstantVM                = new ConstantVM(ownerModule, options.Constant?.Value, dnSpy_AsmEditor_Resources.Parameter_DefaultValueInfo);
            ConstantVM.PropertyChanged    += constantVM_PropertyChanged;
            this.MarshalTypeVM             = new MarshalTypeVM(ownerModule, decompilerService, ownerType != null ? ownerType : ownerMethod?.DeclaringType, ownerMethod);
            MarshalTypeVM.PropertyChanged += marshalTypeVM_PropertyChanged;

            ConstantVM.IsEnabled    = HasDefault;
            MarshalTypeVM.IsEnabled = HasFieldMarshal;
            Reinitialize();
        }
Exemplo n.º 9
0
 void InitializeFrom(MemberRefOptions options)
 {
     this.Class = options.Class;
     this.Name  = options.Name;
     if (IsField)
     {
         var fs = options.Signature as FieldSig;
         TypeSigCreatorVM.TypeSig = fs?.Type;
     }
     else
     {
         MethodSigCreatorVM.MethodSig = options.Signature as MethodSig;
     }
     CustomAttributesVM.InitializeFrom(options.CustomAttributes);
 }
Exemplo n.º 10
0
        public ParamDefVM(ParamDefOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule               = ownerModule;
            this.origOptions               = options;
            this.sequence                  = new UInt16VM(a => { OnPropertyChanged("FullName"); HasErrorUpdated(); });
            this.customAttributesVM        = new CustomAttributesVM(ownerModule, language);
            this.constantVM                = new ConstantVM(ownerModule, options.Constant == null ? null : options.Constant.Value, "Default value for this parameter");
            ConstantVM.PropertyChanged    += constantVM_PropertyChanged;
            this.marshalTypeVM             = new MarshalTypeVM(ownerModule, language, ownerType != null ? ownerType : ownerMethod == null ? null : ownerMethod.DeclaringType, ownerMethod);
            MarshalTypeVM.PropertyChanged += marshalTypeVM_PropertyChanged;

            ConstantVM.IsEnabled    = HasDefault;
            MarshalTypeVM.IsEnabled = HasFieldMarshal;
            Reinitialize();
        }
Exemplo n.º 11
0
 public DeclSecurityVM(DeclSecurityOptions options, ModuleDef ownerModule, ILanguageManager languageManager, TypeDef ownerType, MethodDef ownerMethod)
 {
     this.ownerModule                    = ownerModule;
     this.languageManager                = languageManager;
     this.ownerType                      = ownerType;
     this.ownerMethod                    = ownerMethod;
     this.origOptions                    = options;
     this.customAttributesVM             = new CustomAttributesVM(ownerModule, languageManager);
     CustomAttributesVM.PropertyChanged += CustomAttributesVM_PropertyChanged;
     this.declSecVerEnumListVM           = new EnumListVM(declSecVerList, (a, b) => OnDeclSecVerChanged());
     this.securityActionEnumListVM       = new EnumListVM(secActList, (a, b) => OnSecurityActionChanged());
     this.securityAttributesVM           = new SecurityAttributesVM(ownerModule, languageManager, ownerType, ownerMethod);
     this.SecurityAttributesVM.Collection.CollectionChanged += SecurityAttributesVM_CollectionChanged;
     Reinitialize();
 }
Exemplo n.º 12
0
 public DeclSecurityVM(DeclSecurityOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod)
 {
     this.ownerModule                    = ownerModule;
     this.decompilerService              = decompilerService;
     this.ownerType                      = ownerType;
     this.ownerMethod                    = ownerMethod;
     origOptions                         = options;
     CustomAttributesVM                  = new CustomAttributesVM(ownerModule, decompilerService);
     CustomAttributesVM.PropertyChanged += CustomAttributesVM_PropertyChanged;
     DeclSecVerEnumList                  = new EnumListVM(declSecVerList, (a, b) => OnDeclSecVerChanged());
     SecurityActionEnumList              = new EnumListVM(secActList, (a, b) => OnSecurityActionChanged());
     SecurityAttributesVM                = new SecurityAttributesVM(ownerModule, decompilerService, ownerType, ownerMethod);
     SecurityAttributesVM.Collection.CollectionChanged += SecurityAttributesVM_CollectionChanged;
     Reinitialize();
 }
Exemplo n.º 13
0
        public MethodSpecVM(MethodSpecOptions options, TypeSigCreatorOptions typeSigCreatorOptions)
        {
            this.origOptions           = options;
            this.typeSigCreatorOptions = typeSigCreatorOptions;
            this.customAttributesVM    = new CustomAttributesVM(typeSigCreatorOptions.OwnerModule, typeSigCreatorOptions.LanguageManager);

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

            this.createTypeSigArrayVM = new CreateTypeSigArrayVM(typeSigCreatorOptions, null);

            Reinitialize();
        }
Exemplo n.º 14
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.LanguageManager);

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

            this.typeSigCreatorVM             = new TypeSigCreatorVM(this.typeSigCreatorOptions.Clone(dnSpy_AsmEditor_Resources.CreateFieldTypeSig));
            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();
        }