Ejemplo n.º 1
0
        public CustomAttributeVM(CustomAttributeOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.origOptions = options;
            this.ownerModule = ownerModule;
            this.language    = language;
            this.ownerType   = ownerType;
            this.ownerMethod = ownerMethod;

            this.rawData            = new HexStringVM(a => HasErrorUpdated());
            this.caNamedArgumentsVM = new CANamedArgumentsVM(ownerModule, language, ownerType, ownerMethod, a => !IsRawData && a.Collection.Count < ushort.MaxValue);
            ConstructorArguments.CollectionChanged          += Args_CollectionChanged;
            CANamedArgumentsVM.Collection.CollectionChanged += Args_CollectionChanged;

            Reinitialize();
        }
Ejemplo n.º 2
0
        public CustomAttributeVM(CustomAttributeOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.origOptions = options;
            this.ownerModule = ownerModule;
            this.language = language;
            this.ownerType = ownerType;
            this.ownerMethod = ownerMethod;

            this.rawData = new HexStringVM(a => HasErrorUpdated());
            this.caNamedArgumentsVM = new CANamedArgumentsVM(ownerModule, language, ownerType, ownerMethod, a => !IsRawData && a.Collection.Count < ushort.MaxValue);
            ConstructorArguments.CollectionChanged += Args_CollectionChanged;
            CANamedArgumentsVM.Collection.CollectionChanged += Args_CollectionChanged;

            Reinitialize();
        }
Ejemplo n.º 3
0
        void InitializeFrom(CustomAttributeOptions options)
        {
            IsRawData     = options.RawData != null;
            RawData.Value = options.RawData;
            Constructor   = options.Constructor;
            ConstructorArguments.Clear();
            var sig = Constructor == null ? null : Constructor.MethodSig;

            for (int i = 0; i < options.ConstructorArguments.Count; i++)
            {
                TypeSig type = null;
                if (sig != null && i < sig.Params.Count)
                {
                    type = sig.Params[i];
                }
                ConstructorArguments.Add(new CAArgumentVM(ownerModule, options.ConstructorArguments[i], new TypeSigCreatorOptions(ownerModule, language), type));
            }
            CANamedArgumentsVM.InitializeFrom(options.NamedArguments);
            CreateArguments();
        }
Ejemplo n.º 4
0
 CustomAttributeOptions CopyTo(CustomAttributeOptions options)
 {
     options.Constructor = Constructor;
     options.ConstructorArguments.Clear();
     options.NamedArguments.Clear();
     if (IsRawData)
     {
         options.RawData = RawData.Value.ToArray();
     }
     else
     {
         options.RawData = null;
         int count = Constructor == null ? 0 : Constructor.MethodSig.GetParamCount();
         for (int i = 0; i < count; i++)
         {
             options.ConstructorArguments.Add(ConstructorArguments[i].CreateCAArgument(Constructor.MethodSig.Params[i]));
         }
         options.NamedArguments.AddRange(CANamedArgumentsVM.Collection.Select(a => a.CreateCANamedArgument()));
     }
     return(options);
 }
Ejemplo n.º 5
0
 void InitializeFrom(CustomAttributeOptions options)
 {
     IsRawData = options.RawData != null;
     RawData.Value = options.RawData;
     Constructor = options.Constructor;
     ConstructorArguments.Clear();
     var sig = Constructor == null ? null : Constructor.MethodSig;
     for (int i = 0; i < options.ConstructorArguments.Count; i++) {
         TypeSig type = null;
         if (sig != null && i < sig.Params.Count)
             type = sig.Params[i];
         ConstructorArguments.Add(new CAArgumentVM(ownerModule, options.ConstructorArguments[i], new TypeSigCreatorOptions(ownerModule, language), type));
     }
     CANamedArgumentsVM.InitializeFrom(options.NamedArguments);
     CreateArguments();
 }
Ejemplo n.º 6
0
 CustomAttributeOptions CopyTo(CustomAttributeOptions options)
 {
     options.Constructor = Constructor;
     options.ConstructorArguments.Clear();
     options.NamedArguments.Clear();
     if (IsRawData)
         options.RawData = RawData.Value.ToArray();
     else {
         options.RawData = null;
         int count = Constructor == null ? 0 : Constructor.MethodSig.GetParamCount();
         for (int i = 0; i < count; i++)
             options.ConstructorArguments.Add(ConstructorArguments[i].CreateCAArgument(Constructor.MethodSig.Params[i]));
         options.NamedArguments.AddRange(CANamedArgumentsVM.Collection.Select(a => a.CreateCANamedArgument()));
     }
     return options;
 }