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, attributes, name); if (customAttributes != null && pb != null) { AttributeGen.ApplyList(ref customAttributes, pb.SetCustomAttribute); } }
void IDelayedCompletion.Complete() { if ((adder == null) != (remover == null)) { throw new InvalidOperationException(Properties.Messages.ErrInvalidEventAccessors); } AttributeGen.ApplyList(ref customAttributes, eb.SetCustomAttribute); }
public void Complete() { foreach (TypeGen tg in types) { tg.Complete(); } AttributeGen.ApplyList(ref assemblyAttributes, asm.SetCustomAttribute); AttributeGen.ApplyList(ref moduleAttributes, mod.SetCustomAttribute); }
void IDelayedCompletion.Complete() { LockSignature(); if (HasCode) { GetCode().Complete(); } AttributeGen.ApplyList(ref customAttributes, SetCustomAttribute); }
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, Properties.Messages.ErrInterfaceNotImplemented, 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); }
void IDelayedCompletion.Complete() { AttributeGen.ApplyList(ref customAttributes, pb.SetCustomAttribute); }