ApplyList() static private method

static private ApplyList ( List &customAttributes, Action setCustomAttribute ) : void
customAttributes List
setCustomAttribute Action
return void
Example #1
0
        TypeGen ImplementDelegate()
        {
            TypeGen tg = new TypeGen(owner, name, attrs, typeof(MulticastDelegate), Type.EmptyTypes);

            ConstructorBuilder cb = tg.Public.RuntimeImpl.Constructor()
                                    .Parameter(typeof(object), "object")
                                    .Parameter(typeof(IntPtr), "method")
                                    .GetConstructorBuilder();

            cb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);

            MethodBuilder mb = tg.Public.Virtual.RuntimeImpl.Method(typeof(IAsyncResult), "BeginInvoke")
                               .CopyParameters(Parameters)
                               .UncheckedParameter(typeof(AsyncCallback), "callback")
                               .UncheckedParameter(typeof(object), "object")
                               .GetMethodBuilder();

            mb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);

            mb = tg.Public.Virtual.RuntimeImpl.Method(ReturnType, "EndInvoke")
                 .Parameter(typeof(IAsyncResult), "result")
                 .GetMethodBuilder();
            mb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);

            mb = tg.Public.Virtual.RuntimeImpl.Method(ReturnType, "Invoke")
                 .CopyParameters(Parameters)
                 .GetMethodBuilder();
            mb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);

            AttributeGen.ApplyList(ref customAttributes, tg.TypeBuilder.SetCustomAttribute);

            return(tg);
        }
        internal void Complete(ISignatureGen sig)
        {
            ParameterBuilder pb = sig.DefineParameter(Position, ParameterAttributes, Name);

            if (CustomAttributes != null && pb != null)
            {
                AttributeGen.ApplyList(ref CustomAttributes, pb.SetCustomAttribute);
            }
        }
Example #3
0
        void IDelayedCompletion.Complete()
        {
            if ((adder == null) != (remover == null))
            {
                throw new InvalidOperationException(Properties.Messages.ErrInvalidEventAccessors);
            }

            AttributeGen.ApplyList(ref customAttributes, eb.SetCustomAttribute);
        }
Example #4
0
        public void Complete()
        {
            if (_type != null)
            {
                return;
            }

            if (_owner != null && TypeBuilder.IsValueType)
            {
                if (_fields.Count == 0 && _properties.Count == 0)
                {
                    // otherwise  "Value class has neither fields nor size parameter."
                    Private.ReadOnly.Field(_typeMapper.MapType(typeof(int)), "_____");
                }
            }

            foreach (TypeGen nested in _nestedTypes)
            {
                nested.Complete();
            }

            if (_owner != null)
            {
                // ensure creation of default constructor
                EnsureDefaultConstructor();
            }

            FlushDefinitionQueue();
            FlushCompletionQueue();

            // implement all interfaces
            foreach (InterfaceImplEntry iie in _implementations)
            {
                if (!iie.IsBound)
                {
                    throw new NotImplementedException(string.Format(null, Properties.Messages.ErrInterfaceNotImplemented,
                                                                    iie.InterfaceType, iie.InterfaceMethod.Member));
                }

                TypeBuilder.DefineMethodOverride(iie.BoundMethod.GetMethodBuilder(), (MethodInfo)iie.InterfaceMethod.Member);
            }

            // set indexer name
            if (_indexerName != null)
            {
                CustomAttributeBuilder cab = new CustomAttributeBuilder(
                    TypeMapper.MapType(typeof(DefaultMemberAttribute)).GetConstructor(new Type[] { TypeMapper.MapType(typeof(string)) }),
                    new object[] { _indexerName });
                TypeBuilder.SetCustomAttribute(cab);
            }

            AttributeGen.ApplyList(ref _customAttributes, TypeBuilder.SetCustomAttribute);

            _type = TypeBuilder.CreateType();

            _typeMapper.TypeInfo.UnregisterProvider(TypeBuilder);
        }
Example #5
0
        public void Complete(ISignatureGen sig)
        {
            ParameterBuilder pb = sig.DefineParameter(position, attributes, name);

            if (customAttributes != null && pb != null)
            {
                AttributeGen.ApplyList(ref customAttributes, pb.SetCustomAttribute);
            }
        }
Example #6
0
        void IDelayedCompletion.Complete()
        {
            if ((adder == null) != (remover == null))
            {
                throw new InvalidOperationException("Either none or both 'Add' and 'Remove' event accessors must be defined");
            }

            AttributeGen.ApplyList(ref customAttributes, eb.SetCustomAttribute);
        }
Example #7
0
        public void Complete()
        {
            foreach (TypeGen tg in types)
            {
                tg.Complete();
            }

            AttributeGen.ApplyList(ref assemblyAttributes, asm.SetCustomAttribute);
            AttributeGen.ApplyList(ref moduleAttributes, mod.SetCustomAttribute);
        }
Example #8
0
        public void Complete()
        {
            foreach (TypeGen tg in _types)
            {
                tg.Complete();
            }

            AttributeGen.ApplyList(ref _assemblyAttributes, AssemblyBuilder.SetCustomAttribute);
            AttributeGen.ApplyList(ref _moduleAttributes, ModuleBuilder.SetCustomAttribute);
            WriteAssemblyAttributes(_compilerOptions, AssemblyBuilder.GetName().Name, AssemblyBuilder);
        }
Example #9
0
        void IDelayedCompletion.Complete()
        {
            LockSignature();

            if (HasCode)
            {
                GetCode().Complete();
            }

            AttributeGen.ApplyList(ref _customAttributes, SetCustomAttribute);
        }
Example #10
0
        public void Complete()
        {
            if (type != null)
            {
                return;
            }

            foreach (TypeGen nested in nestedTypes)
            {
                nested.Complete();
            }

            // ensure creation of default constructor
            EnsureDefaultConstructor();

            FlushDefinitionQueue();
            FlushCompletionQueue();

            // implement all interfaces
            foreach (InterfaceImplEntry iie in implementations)
            {
                if (!iie.IsBound && iie.InterfaceMethod.Name == "get_ReturnValue")
                {
                }
                if (!iie.IsBound && iie.InterfaceMethod.Name != "get_ReturnValue")
                {
                    throw new NotImplementedException(string.Format(null, "Method '{1}' of interface '{0}' is not implemented",
                                                                    iie.InterfaceType, iie.InterfaceMethod.Member));
                }

                tb.DefineMethodOverride(iie.BoundMethod.GetMethodBuilder(), (MethodInfo)iie.InterfaceMethod.Member);
            }

            // set indexer name
            if (indexerName != null)
            {
                CustomAttributeBuilder cab = new CustomAttributeBuilder(
                    typeof(DefaultMemberAttribute).GetConstructor(new Type[] { typeof(string) }),
                    new object[] { indexerName });
                tb.SetCustomAttribute(cab);
            }

            AttributeGen.ApplyList(ref customAttributes, tb.SetCustomAttribute);

            type = tb.CreateType();

            TypeInfo.UnregisterProvider(tb);
        }
Example #11
0
        public void Complete()
        {
            if (_type != null)
            {
                return;
            }

            foreach (TypeGen nested in _nestedTypes)
            {
                nested.Complete();
            }

            // ensure creation of default constructor
            EnsureDefaultConstructor();

            FlushDefinitionQueue();
            FlushCompletionQueue();

            // implement all interfaces
            foreach (InterfaceImplEntry iie in _implementations)
            {
                if (!iie.IsBound)
                {
                    throw new NotImplementedException(string.Format(null, Messages.ErrInterfaceNotImplemented,
                                                                    iie.InterfaceType, iie.InterfaceMethod.Member));
                }

                TypeBuilder.DefineMethodOverride(iie.BoundMethod.GetMethodBuilder(), (MethodInfo)iie.InterfaceMethod.Member);
            }

            // set indexer name
            if (_indexerName != null)
            {
                CustomAttributeBuilder cab = new CustomAttributeBuilder(
                    TypeMapper.MapType(typeof(DefaultMemberAttribute)).GetConstructor(new Type[] { TypeMapper.MapType(typeof(string)) }),
                    new object[] { _indexerName });
                TypeBuilder.SetCustomAttribute(cab);
            }

            AttributeGen.ApplyList(ref _customAttributes, TypeBuilder.SetCustomAttribute);

            _type = TypeBuilder.CreateType();

            _typeMapper.TypeInfo.UnregisterProvider(TypeBuilder);
        }
Example #12
0
        TypeGen ImplementDelegate()
        {
            TypeGen tg;

            if (_owner == null)
            {
                tg = new TypeGen(_owner2, _name, _attrs, _owner2.TypeMapper.MapType(typeof(MulticastDelegate)), Type.EmptyTypes, TypeMapper);
            }
            else
            {
                tg = new TypeGen(_owner, _name, _attrs, _owner.TypeMapper.MapType(typeof(MulticastDelegate)), Type.EmptyTypes, TypeMapper);
            }

            ConstructorBuilder cb = tg.Public.RuntimeImpl.Constructor()
                                    .Parameter(Helpers.TypeOf <object>(TypeMapper), "object")
                                    .Parameter(Helpers.TypeOf <IntPtr>(TypeMapper), "method")
                                    .GetConstructorBuilder();

            cb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);

            MethodBuilder mb = tg.Public.Virtual.RuntimeImpl.Method(Helpers.TypeOf <IAsyncResult>(TypeMapper), "BeginInvoke")
                               .CopyParameters(Parameters)
                               .UncheckedParameter(Helpers.TypeOf <AsyncCallback>(TypeMapper), "callback")
                               .UncheckedParameter(Helpers.TypeOf <object>(TypeMapper), "object")
                               .GetMethodBuilder();

            mb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);

            mb = tg.Public.Virtual.RuntimeImpl.Method(ReturnType, "EndInvoke")
                 .Parameter(Helpers.TypeOf <IAsyncResult>(TypeMapper), "result")
                 .GetMethodBuilder();
            mb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);

            mb = tg.Public.Virtual.RuntimeImpl.Method(ReturnType, "Invoke")
                 .CopyParameters(Parameters)
                 .GetMethodBuilder();
            mb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);

            AttributeGen.ApplyList(ref _customAttributes, tg.TypeBuilder.SetCustomAttribute);

            return(tg);
        }
Example #13
0
 void IDelayedCompletion.Complete()
 {
     AttributeGen.ApplyList(ref _customAttributes, _fb.SetCustomAttribute);
 }