Exemple #1
0
 public CILCustomAttribute AddCustomAttribute(CILConstructor ctor, IEnumerable <CILCustomAttributeTypedArgument> ctorArgs, IEnumerable <CILCustomAttributeNamedArgument> namedArgs)
 {
     lock (this.attributes.Lock)
     {
         var result = CILCustomAttributeFactory.NewAttribute(this, ctor, ctorArgs, namedArgs);
         this.attributes.Value.Add(result);
         return(result);
     }
 }
Exemple #2
0
        internal CILCustomAttributeContainerImpl(
            CILReflectionContextImpl ctx,
            Int32 anID,
            CILElementKind kind,
            Func <CustomAttributeDataEventArgs> evtArgsFunc
            )
            : base(ctx, anID)
        {
            ArgumentValidator.ValidateNotNull("Reflection context", ctx);

            InitFields(
                ref this.cilKind,
                ref this.attributes,
                kind,
                new LazyWithLock <ListProxy <CILCustomAttribute> >(() =>
            {
                var evtArgs = evtArgsFunc();
                ctx.LaunchCustomAttributeDataLoadEvent(evtArgs);
                var thisElement = (CILCustomAttributeContainer)this.context.Cache.ResolveAnyID(this.cilKind, this.id);
                return(ctx.CollectionsFactory.NewListProxy <CILCustomAttribute>(new List <CILCustomAttribute>(evtArgs.CustomAttributeData.Select(tuple => CILCustomAttributeFactory.NewAttribute(thisElement, tuple.Item1, tuple.Item2, tuple.Item3)))));
            })
                );
        }