Exemplo n.º 1
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.º 2
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.º 3
0
 GenericParamOptions CopyTo(GenericParamOptions options)
 {
     options.Number = Number.Value;
     options.Flags  = Attributes;
     options.Name   = Name;
     options.Kind   = TypeSigCreator.TypeSig.ToTypeDefOrRef();
     options.GenericParamConstraints.Clear();
     options.GenericParamConstraints.AddRange(TypeDefOrRefAndCAsVM.Collection.Select(a => a.CreateTypeDefOrRefAndCAOptions().CreateGenericParamConstraint(ownerModule)));
     options.CustomAttributes.Clear();
     options.CustomAttributes.AddRange(CustomAttributesVM.Collection.Select(a => a.CreateCustomAttributeOptions().Create()));
     return(options);
 }
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(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.º 6
0
 GenericParamOptions CopyTo(GenericParamOptions options)
 {
     options.Number = Number.Value;
     options.Flags = Attributes;
     options.Name = Name;
     options.Kind = TypeSigCreator.TypeSig.ToTypeDefOrRef();
     options.GenericParamConstraints.Clear();
     options.GenericParamConstraints.AddRange(TypeDefOrRefAndCAsVM.Collection.Select(a => a.CreateTypeDefOrRefAndCAOptions().CreateGenericParamConstraint(ownerModule)));
     options.CustomAttributes.Clear();
     options.CustomAttributes.AddRange(CustomAttributesVM.Collection.Select(a => a.CreateCustomAttributeOptions().Create()));
     return options;
 }