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(); }
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(); }
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(); }
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); }
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(); }
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; }