GetRemoveMethod() public method

public GetRemoveMethod ( ) : MethodInfo
return MethodInfo
 public RemoveEventDecoratorWeaver(IEventTypeBuilder eventTypeBuilder, EventInfo @event, IWeavingSettings weavingSettings)
     : base(@event.GetRemoveMethod(), weavingSettings)
 {
     MethodEndWeaver = new MethodEndWeaver();
     MethodScopeWeaver = new RemoveEventDecoratorScopeWeaver(method, weavingSettings);
     MethodDefintionWeaver = new RemoveEventMethodSignatureWeaver(eventTypeBuilder, weavingSettings.TypeDefinition);
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="EventMemberDescriptor" /> class.
 /// </summary>
 /// <param name="ei">The ei.</param>
 /// <param name="accessMode">The access mode.</param>
 public EventMemberDescriptor(EventInfo ei, InteropAccessMode accessMode = InteropAccessMode.Default)
 {
     CheckEventIsCompatible(ei, true);
     EventInfo = ei;
     m_Add = ei.GetAddMethod(true);
     m_Remove = ei.GetRemoveMethod(true);
     IsStatic = m_Add.IsStatic;
 }
Esempio n. 3
0
		public ReflectionEventDescriptor (EventInfo eventInfo) : base (eventInfo.Name, (Attribute[]) eventInfo.GetCustomAttributes (true))
		{
			_eventInfo = eventInfo;
			_componentType = eventInfo.DeclaringType;
			_eventType = eventInfo.EventHandlerType;

			add_method = eventInfo.GetAddMethod ();
			remove_method = eventInfo.GetRemoveMethod ();
		}
        private void BuildRemover(TypeBuilder typeBuilder, EventInfo contractProperty, EventBuilder builder)
        {
            var removeMethod = contractProperty.GetRemoveMethod();

            if (null != removeMethod)
            {
                var removeMethodBuilder = new ProxyMethodImplementationStrategy().BuildMethodProxy(typeBuilder, removeMethod);
                builder.SetRemoveOnMethod(removeMethodBuilder);
            }
        }
		/// <summary>
		/// Tries to create a new StandardUserDataEventDescriptor, returning <c>null</c> in case the method is not 
		/// visible to script code.
		/// </summary>
		/// <param name="ei">The EventInfo.</param>
		/// <param name="accessMode">The <see cref="InteropAccessMode" /></param>
		/// <returns>A new StandardUserDataEventDescriptor or null.</returns>
		public static EventMemberDescriptor TryCreateIfVisible(EventInfo ei, InteropAccessMode accessMode)
		{
			if (!CheckEventIsCompatible(ei, false))
				return null;

			if (ei.GetVisibilityFromAttributes() ?? (ei.GetAddMethod().IsPublic && ei.GetRemoveMethod().IsPublic))
				return new EventMemberDescriptor(ei, accessMode);

			return null;
		}
		/// <summary>
		/// Checks if the event is compatible with a standard descriptor
		/// </summary>
		/// <param name="ei">The EventInfo.</param>
		/// <param name="throwException">if set to <c>true</c> an exception with the proper error message is thrown if not compatible.</param>
		/// <returns></returns>
		/// <exception cref="System.ArgumentException">
		/// Thrown if throwException is <c>true</c> and one of this applies:
		/// The event is declared in a value type
		/// or
		/// The event does not have both add and remove methods 
		/// or
		/// The event handler type doesn't implement a public Invoke method
		/// or
		/// The event handler has a return type which is not System.Void
		/// or
		/// The event handler has more than MAX_ARGS_IN_DELEGATE parameters
		/// or
		/// The event handler has a value type parameter or a by ref parameter
		/// or
		/// The event handler signature is not a valid method according to <see cref="MethodMemberDescriptor.CheckMethodIsCompatible"/>
		/// </exception>
		public static bool CheckEventIsCompatible(EventInfo ei, bool throwException)
		{
			if (ei.DeclaringType.IsValueType)
			{
				if (throwException) throw new ArgumentException("Events are not supported on value types");
				return false;
			}

			if ((ei.GetAddMethod(true) == null) || (ei.GetRemoveMethod(true) == null))
			{
				if (throwException) throw new ArgumentException("Event must have add and remove methods");
				return false;
			}

			MethodInfo invoke = ei.EventHandlerType.GetMethod("Invoke");

			if (invoke == null)
			{
				if (throwException) throw new ArgumentException("Event handler type doesn't seem to be a delegate");
				return false;
			}

			if (!MethodMemberDescriptor.CheckMethodIsCompatible(invoke, throwException))
				return false;

			if (invoke.ReturnType != typeof(void))
			{
				if (throwException) throw new ArgumentException("Event handler cannot have a return type");
				return false;
			}

			ParameterInfo[] pars = invoke.GetParameters();

			if (pars.Length > MAX_ARGS_IN_DELEGATE)
			{
				if (throwException) throw new ArgumentException(string.Format("Event handler cannot have more than {0} parameters", MAX_ARGS_IN_DELEGATE));
				return false;
			}

			foreach (ParameterInfo pi in pars)
			{
				if (pi.ParameterType.IsValueType)
				{
					if (throwException) throw new ArgumentException("Event handler cannot have value type parameters");
					return false;
				}
				else if (pi.ParameterType.IsByRef)
				{
					if (throwException) throw new ArgumentException("Event handler cannot have by-ref type parameters");
					return false;
				}
			}

			return true;
		}
 private EventBuilder ImplementEvent(TypeBuilder typeBuilder, EventInfo eventToImplement, Type targetInterface)
 {
     var eventBuilder = typeBuilder.DefineEvent(eventToImplement.Name, EventAttributes.None, eventToImplement.EventHandlerType);
     var addMethodInfo = eventToImplement.GetAddMethod();
     var removeMethodInfo = eventToImplement.GetRemoveMethod();
     var addMethodBuilder = ImplementMethod(typeBuilder, addMethodInfo, targetInterface);
     var removeMethodBuilder = ImplementMethod(typeBuilder, removeMethodInfo, targetInterface);
     eventBuilder.SetAddOnMethod(addMethodBuilder);
     eventBuilder.SetRemoveOnMethod(removeMethodBuilder);
     return eventBuilder;
 }
Esempio n. 8
0
 /// <summary>
 /// Implements the event.
 /// </summary>
 /// <param name="eventToImplement">The event to implement.</param>
 /// <param name="targetInterface">The target interface.</param>
 /// <returns></returns>
 protected override EventBuilder ImplementEvent(EventInfo eventToImplement, Type targetInterface)
 {
     EventBuilder eventBuilder = this.TypeBuilder.DefineEvent(eventToImplement.Name, EventAttributes.None, eventToImplement.EventHandlerType);
     MethodInfo addMethodInfo = eventToImplement.GetAddMethod();
     MethodInfo removeMethodInfo = eventToImplement.GetRemoveMethod();
     MethodBuilder addMethodBuilder = this.ImplementMethod(addMethodInfo, targetInterface);
     MethodBuilder removeMethodBuilder = this.ImplementMethod(removeMethodInfo, targetInterface);
     eventBuilder.SetAddOnMethod(addMethodBuilder);
     eventBuilder.SetRemoveOnMethod(removeMethodBuilder);
     return eventBuilder;
 }
Esempio n. 9
0
		/// <summary>
		/// Tries to create a new StandardUserDataEventDescriptor, returning <c>null</c> in case the method is not 
		/// visible to script code.
		/// </summary>
		/// <param name="ei">The EventInfo.</param>
		/// <param name="accessMode">The <see cref="InteropAccessMode" /></param>
		/// <returns>A new StandardUserDataEventDescriptor or null.</returns>
		public static EventMemberDescriptor TryCreateIfVisible(EventInfo ei, InteropAccessMode accessMode)
		{
			if (!CheckEventIsCompatible(ei, false))
				return null;

	        MethodInfo addm = ei.GetAddMethod();
	        MethodInfo remm = ei.GetRemoveMethod();

	        if (ei.GetVisibilityFromAttributes() ?? ((remm != null && remm.IsPublic) && (addm != null && addm.IsPublic)))
	            return new EventMemberDescriptor(ei, accessMode);

			return null;
		}
        public ReflectionEvent(EventInfo eventInfo, XmlDocument docs)
        {
            FullyQualifiedName = String.Concat(eventInfo.DeclaringType.FullName, ".", eventInfo.Name);

            if (docs != null) {
                XmlNode node = docs.SelectSingleNode ("/Type/Members/Member[@MemberName='" + eventInfo.Name + "']/Docs/summary");
                if (node != null) {
                    Documentation = node.InnerXml;
                }
            }

            // get modifiers
            MethodInfo methodBase = null;
            try {
                methodBase = eventInfo.GetAddMethod(true);
            } catch (Exception) {}

            if (methodBase == null) {
                try {
                    methodBase = eventInfo.GetRemoveMethod(true);
                } catch (Exception) {}
            }

            if (methodBase != null) {
                if (methodBase.IsStatic) {
                    modifiers |= ModifierEnum.Static;
                }

                if (methodBase.IsAssembly) {
                    modifiers |= ModifierEnum.Internal;
                }

                if (methodBase.IsPrivate) { // I assume that private is used most and public last (at least should be)
                    modifiers |= ModifierEnum.Private;
                } else if (methodBase.IsFamily) {
                    modifiers |= ModifierEnum.Protected;
                } else if (methodBase.IsPublic) {
                    modifiers |= ModifierEnum.Public;
                } else if (methodBase.IsFamilyOrAssembly) {
                    modifiers |= ModifierEnum.ProtectedOrInternal;
                } else if (methodBase.IsFamilyAndAssembly) {
                    modifiers |= ModifierEnum.Protected;
                    modifiers |= ModifierEnum.Internal;
                }
            } else { // assume public property, if no methodBase could be get.
                modifiers = ModifierEnum.Public;
            }

            returnType = new ReflectionReturnType(eventInfo.EventHandlerType );
        }
Esempio n. 11
0
		public ReflectionEvent(EventInfo eventInfo, IClass declaringType) : base(declaringType, eventInfo.Name)
		{
			this.ReturnType = ReflectionReturnType.Create(this, eventInfo.EventHandlerType, attributeProvider: eventInfo);
			
			// get modifiers
			MethodInfo methodBase = null;
			try {
				methodBase = eventInfo.GetAddMethod(true);
			} catch (Exception) {}
			
			if (methodBase == null) {
				try {
					methodBase = eventInfo.GetRemoveMethod(true);
				} catch (Exception) {}
			}
			
			ModifierEnum modifiers  = ModifierEnum.None;
			if (methodBase != null) {
				if (methodBase.IsStatic) {
					modifiers |= ModifierEnum.Static;
				}
				
				if (methodBase.IsAssembly) {
					modifiers |= ModifierEnum.Internal;
				}
				
				if (methodBase.IsPrivate) { // I assume that private is used most and public last (at least should be)
					modifiers |= ModifierEnum.Private;
				} else if (methodBase.IsFamily || methodBase.IsFamilyOrAssembly) {
					modifiers |= ModifierEnum.Protected;
				} else if (methodBase.IsPublic) {
					modifiers |= ModifierEnum.Public;
				} else {
					modifiers |= ModifierEnum.Internal;
				}
				
				if (methodBase.IsFinal) {
					modifiers |= ModifierEnum.Sealed;
				} else if (methodBase.IsAbstract) {
					modifiers |= ModifierEnum.Abstract;
				} else if (methodBase.IsVirtual) {
					modifiers |= ModifierEnum.Virtual;
				}
			} else {
				// assume public property, if no methodBase could be get.
				modifiers = ModifierEnum.Public;
			}
			this.Modifiers = modifiers;
			
		}
Esempio n. 12
0
        /// <summary>
        /// Verifies that two events are equivalent.
        /// </summary>
        /// <param name="actual">The actual event information.</param>
        /// <param name="expected">The expected event information.</param>
        /// <param name="isExplicit">A value indicating whether the actual event is implemented explicitly.</param>
        public static void AreEquivalent(EventInfo actual, EventInfo expected, bool isExplicit)
        {
            Assert.That(actual, Is.Not.Null);
            Assert.That(expected, Is.Not.Null);

            // Check member properties.
            AreMembersEquivalent(actual, expected);

            // Check event properties.
            Assert.That(actual.Attributes, Is.EqualTo(expected.Attributes));
            Assert.That(actual.IsMulticast, Is.EqualTo(expected.IsMulticast));
            Assert.That(actual.IsSpecialName, Is.EqualTo(expected.IsSpecialName));

            // Check event handler type.
            AreTypesEquivalent(actual.EventHandlerType, expected.EventHandlerType);

            // Check event methods.
            InternalAreEquivalent(actual.GetAddMethod(), expected.GetAddMethod(), isExplicit);
            InternalAreEquivalent(actual.GetRemoveMethod(), expected.GetRemoveMethod(), isExplicit);
            InternalAreEquivalent(actual.GetRaiseMethod(), expected.GetRaiseMethod(), isExplicit);
        }
Esempio n. 13
0
        protected EventInfo[] GetEvents_impl(BindingFlags bf, Type reftype)
        {
            ArrayList        l = new ArrayList();
            bool             match;
            MethodAttributes mattrs;
            MethodInfo       accessor;

            initialize();

            EventInfo[] events = GetEvents_internal(reftype);

            for (int i = 0; i < events.Length; i++)
            {
                EventInfo c = events [i];

                match    = false;
                accessor = c.GetAddMethod(true);
                if (accessor == null)
                {
                    accessor = c.GetRemoveMethod(true);
                }
                if (accessor == null)
                {
                    continue;
                }
                mattrs = accessor.Attributes;
                if ((mattrs & MethodAttributes.MemberAccessMask) == MethodAttributes.Public)
                {
                    if ((bf & BindingFlags.Public) != 0)
                    {
                        match = true;
                    }
                }
                else
                {
                    if ((bf & BindingFlags.NonPublic) != 0)
                    {
                        match = true;
                    }
                }
                if (!match)
                {
                    continue;
                }
                match = false;
                if ((mattrs & MethodAttributes.Static) != 0)
                {
                    if ((bf & BindingFlags.Static) != 0)
                    {
                        match = true;
                    }
                }
                else
                {
                    if ((bf & BindingFlags.Instance) != 0)
                    {
                        match = true;
                    }
                }
                if (!match)
                {
                    continue;
                }
                l.Add(c);
            }
            EventInfo[] result = new EventInfo [l.Count];
            l.CopyTo(result);
            return(result);
        }
Esempio n. 14
0
 public static MethodInfo?GetRemoveMethod(this EventInfo eventInfo, bool nonPublic)
 {
     Requires.NotNull(eventInfo, nameof(eventInfo));
     return(eventInfo.GetRemoveMethod(nonPublic));
 }
Esempio n. 15
0
        static private void AppendEventInfo(StringBuilder builder, Type type, EventInfo info)
        {
            int propertyStart = builder.Length;

            AppendParameterType(builder, info.EventHandlerType);
            builder.Append(" ");
            builder.Append(info.Name);

            builder.Append(" {");
            bool gettable = AppendPropertyMethod(builder, type, info.GetAddMethod(), "add");
            bool settable = AppendPropertyMethod(builder, type, info.GetRemoveMethod(), "remove");
            if (gettable || settable)
            {
                builder.Append(" }");
                builder.Append(Environment.NewLine);
            }
            else
            {
                builder.Length = propertyStart;
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Defines an event based on the specified event.
        /// </summary>
        /// <param name="typeBuilder">The type builder.</param>
        /// <param name="eventInfo">The event information.</param>
        /// <param name="isExplicit">A value indicating whether the specified event should be implemented explicitly.</param>
        /// <param name="methodBuilderFactory">The method builder factory function.</param>
        /// <returns>The event builder.</returns>
        public static void DefineEvent(this TypeBuilder typeBuilder,
                                       EventInfo eventInfo,
                                       bool isExplicit,
                                       Func<MethodInfo, bool, MethodBuilder> methodBuilderFactory)
        {
            if (typeBuilder == null)
                throw new ArgumentNullException("typeBuilder");

            if (eventInfo == null)
                throw new ArgumentNullException("eventInfo");

            if (methodBuilderFactory == null)
                throw new ArgumentNullException("methodBuilderFactory");

            // Define event.
            var eventName = isExplicit ? eventInfo.GetFullName() : eventInfo.Name;

            var eventBuilder = typeBuilder.DefineEvent(
                eventName,
                eventInfo.Attributes,
                eventInfo.EventHandlerType);

            // Build event add method.
            var addMethodInfo = eventInfo.GetAddMethod();
            var addMethodBuilder = methodBuilderFactory(addMethodInfo, isExplicit);

            eventBuilder.SetAddOnMethod(addMethodBuilder);

            // Build event remove method.
            var removeMethodInfo = eventInfo.GetRemoveMethod();
            var removeMethodBuilder = methodBuilderFactory(removeMethodInfo, isExplicit);

            eventBuilder.SetRemoveOnMethod(removeMethodBuilder);

            // Build event raise method.
            var raiseMethodInfo = eventInfo.GetRaiseMethod();

            if (raiseMethodInfo != null)
            {
                var methodBuilder = methodBuilderFactory(raiseMethodInfo, isExplicit);

                eventBuilder.SetRaiseMethod(methodBuilder);
            }
        }
Esempio n. 17
0
 /// <summary>
 /// Throws a <see cref="StaticPublisherEventException"/> if the published event is defined static.
 /// </summary>
 /// <param name="publishedEvent">The published event.</param>
 /// <exception cref="StaticPublisherEventException">Thrown if the published event is defined static.</exception>
 private static void ThrowIfEventIsStatic(EventInfo publishedEvent)
 {
     if (publishedEvent.GetAddMethod().IsStatic || publishedEvent.GetRemoveMethod().IsStatic)
     {
         throw new StaticPublisherEventException(publishedEvent);
     }
 }
            public StdEventInfo(EventInfo ei)
            {
                this.ei = ei;
                this.name = ei.Name;

                this.mi = ei.GetAddMethod();
                if (mi == null)
                    mi = ei.GetRemoveMethod();
                // mi will remain null for abstract properties
            }
Esempio n. 19
0
 private void detachEventHandler(EventInfo @event, Delegate d, object realButton)
 {
     @event.GetRemoveMethod().Invoke(realButton, new object[] { d });
 }
Esempio n. 20
0
 private void ThrowIfEventIsStatic(EventInfo publishedEvent)
 {
     if (publishedEvent.GetAddMethod().IsStatic || publishedEvent.GetRemoveMethod().IsStatic)
     {
         throw new EventBrokerException(String.Format(CultureInfo.CurrentCulture,
             Properties.Resources.StaticPublisherNotAllowed, EventName));
     }
 }
Esempio n. 21
0
 private static void GuardRemoveMethodExists(EventInfo targetEvent)
 {
     if (targetEvent.GetRemoveMethod() == null)
     {
         throw new ArgumentException(string.Format("The event '{0}' does not have a public Remove method",
                                                   targetEvent.Name));
     }
 }
Esempio n. 22
0
 public DynamicEvent(EventInfo eventInfo, object instance)
 {
     _addMethod = new DynamicMethod(eventInfo.GetAddMethod(true), instance);
     _removeMethod = new DynamicMethod(eventInfo.GetRemoveMethod(true), instance);
 }
Esempio n. 23
0
        private static void MakeEvent(ModuleBuilder builder, EventInfo info, TypeBuilder typeBuilder, Type contextType, bool defaultImp)
        {
            var tName = info.Name;
            var tAddMethod = info.GetAddMethod();
            var tRemoveMethod = info.GetRemoveMethod();
            var tReturnType = info.EventHandlerType;

            var tCallSiteInvokeName = string.Format("Impromptu_Callsite_{1}_{0}", Guid.NewGuid().ToString("N"), tName);
            var tCStp = DefineBuilderForCallSite(builder, tCallSiteInvokeName);

            var tInvokeIsEvent = "Invoke_IsEvent";
            var tInvokeIseventFuncType = tCStp.DefineCallsiteField(tInvokeIsEvent, typeof (bool));

            var tInvokeAddAssign = "Invoke_AddAssign";
            var tInvokeAddAssignFuncType = tCStp.DefineCallsiteField(tInvokeAddAssign, typeof (object), tReturnType);

            var tInvokeSubtractAssign = "Invoke_SubtractAssign";
            var tInvokeSubtractAssignFuncType = tCStp.DefineCallsiteField(tInvokeSubtractAssign, typeof (object), tReturnType);

            var tAddParamTypes = tRemoveMethod.GetParameters().Select(it => it.ParameterType).ToArray();
            var tInvokeAdd = "Invoke_Add";
            var tInvokeAddFuncType = tCStp.DefineCallsiteField(tInvokeAdd, typeof (object), tAddParamTypes);

            var tRemoveParamTypes = tRemoveMethod.GetParameters().Select(it => it.ParameterType).ToArray();
            var tInvokeRemove = "Invoke_Remove";
            var tInvokeRemoveFuncType = tCStp.DefineCallsiteField(tInvokeRemove, typeof (object), tRemoveParamTypes);

            var tInvokeGet = "Invoke_Get";
            var tInvokeGetFuncType = tCStp.DefineCallsiteField(tInvokeGet, typeof (object));

            var tInvokeSet = "Invoke_Set";

            var tInvokeSetFuncType = tCStp.DefineCallsiteField(tInvokeSet, typeof (object), typeof (object));

            var tCallSite = tCStp.CreateType();

            var tMp = typeBuilder.DefineEvent(tName, EventAttributes.None, tReturnType);

            //AddMethod
            var tPublicPrivate = MethodAttributes.Public;
            var tAddPrefixName = tAddMethod.Name;
            if (!defaultImp) {
                tAddPrefixName = String.Format("{0}.{1}", info.DeclaringType.FullName, tAddPrefixName);

                tPublicPrivate = MethodAttributes.Private;
            }

            var tAddBuilder = typeBuilder.DefineMethod(tAddPrefixName,
                tPublicPrivate | MethodAttributes.SpecialName | MethodAttributes.HideBySig | MethodAttributes.Virtual | MethodAttributes.Final | MethodAttributes.NewSlot,
                typeof (void),
                tAddParamTypes);

            if (!defaultImp) {
                typeBuilder.DefineMethodOverride(tAddBuilder, info.GetAddMethod());
            }

            foreach (var tParam in tAddMethod.GetParameters()) {
                tAddBuilder.DefineParameter(tParam.Position + 1, AttributesForParam(tParam), tParam.Name);
            }

            var tIlGen = tAddBuilder.GetILGenerator();

            var tIsEventField = tCallSite.GetFieldEvenIfGeneric(tInvokeIsEvent);

            using (tIlGen.EmitBranchTrue(gen => gen.Emit(OpCodes.Ldsfld, tIsEventField))) {
                tIlGen.EmitDynamicIsEventBinder(CSharpBinderFlags.None, tName, contextType);
                tIlGen.EmitCallsiteCreate(tInvokeIseventFuncType);
                tIlGen.Emit(OpCodes.Stsfld, tIsEventField);
            }

            var tSetField = tCallSite.GetFieldEvenIfGeneric(tInvokeSet);
            var tGetField = tCallSite.GetFieldEvenIfGeneric(tInvokeGet);

            using (tIlGen.EmitBranchTrue(
                load => load.EmitInvocation(
                    target => target.EmitInvocation(
                        t => t.Emit(OpCodes.Ldsfld, tIsEventField),
                        i => i.Emit(OpCodes.Ldfld, tIsEventField.FieldType.GetFieldEvenIfGeneric("Target"))
                        ),
                    invoke => invoke.EmitCallInvokeFunc(tInvokeIseventFuncType),
                    param => param.Emit(OpCodes.Ldsfld, tIsEventField),
                    param => param.EmitInvocation(
                        t => t.Emit(OpCodes.Ldarg_0),
                        i => i.Emit(OpCodes.Call, typeof (ActLikeProxy).GetProperty("Original").GetGetMethod())
                        )
                    )
                )
                ) //if IsEvent Not True
            {
                using (tIlGen.EmitBranchTrue(gen => gen.Emit(OpCodes.Ldsfld, tSetField))) {
                    tIlGen.EmitDynamicSetBinderDynamicParams(CSharpBinderFlags.ValueFromCompoundAssignment, tName, contextType, typeof (Object));
                    tIlGen.EmitCallsiteCreate(tInvokeSetFuncType);
                    tIlGen.Emit(OpCodes.Stsfld, tSetField);
                }

                var tAddAssigneField = tCallSite.GetFieldEvenIfGeneric(tInvokeAddAssign);

                using (tIlGen.EmitBranchTrue(gen => gen.Emit(OpCodes.Ldsfld, tAddAssigneField))) {
                    tIlGen.EmitDynamicBinaryOpBinder(CSharpBinderFlags.None, ExpressionType.AddAssign, contextType, tReturnType);
                    tIlGen.EmitCallsiteCreate(tInvokeAddAssignFuncType);
                    tIlGen.Emit(OpCodes.Stsfld, tAddAssigneField);
                }

                using (tIlGen.EmitBranchTrue(gen => gen.Emit(OpCodes.Ldsfld, tGetField))) {
                    tIlGen.EmitDynamicGetBinder(CSharpBinderFlags.None, tName, contextType);
                    tIlGen.EmitCallsiteCreate(tInvokeGetFuncType);
                    tIlGen.Emit(OpCodes.Stsfld, tGetField);
                }

                tIlGen.Emit(OpCodes.Ldsfld, tSetField);
                tIlGen.Emit(OpCodes.Ldfld, tSetField.FieldType.GetFieldEvenIfGeneric("Target"));
                tIlGen.Emit(OpCodes.Ldsfld, tSetField);
                tIlGen.Emit(OpCodes.Ldarg_0);
                tIlGen.Emit(OpCodes.Call, typeof (ActLikeProxy).GetProperty("Original").GetGetMethod());

                tIlGen.Emit(OpCodes.Ldsfld, tAddAssigneField);
                tIlGen.Emit(OpCodes.Ldfld, tAddAssigneField.FieldType.GetFieldEvenIfGeneric("Target"));
                tIlGen.Emit(OpCodes.Ldsfld, tAddAssigneField);

                tIlGen.Emit(OpCodes.Ldsfld, tGetField);
                tIlGen.Emit(OpCodes.Ldfld, tGetField.FieldType.GetFieldEvenIfGeneric("Target"));
                tIlGen.Emit(OpCodes.Ldsfld, tGetField);
                tIlGen.Emit(OpCodes.Ldarg_0);
                tIlGen.Emit(OpCodes.Call, typeof (ActLikeProxy).GetProperty("Original").GetGetMethod());

                tIlGen.EmitCallInvokeFunc(tInvokeGetFuncType);

                tIlGen.Emit(OpCodes.Ldarg_1);
                tIlGen.EmitCallInvokeFunc(tInvokeAddAssignFuncType);

                tIlGen.EmitCallInvokeFunc(tInvokeSetFuncType);
                tIlGen.Emit(OpCodes.Pop);
                tIlGen.Emit(OpCodes.Ret);
            }

            var tAddCallSiteField = tCallSite.GetFieldEvenIfGeneric(tInvokeAdd);

            using (tIlGen.EmitBranchTrue(gen => gen.Emit(OpCodes.Ldsfld, tAddCallSiteField))) {
                tIlGen.EmitDynamicMethodInvokeBinder(
                    CSharpBinderFlags.InvokeSpecialName | CSharpBinderFlags.ResultDiscarded,
                    tAddMethod.Name,
                    contextType,
                    tAddMethod.GetParameters(),
                    Enumerable.Repeat(default(string),
                        tAddParamTypes.Length));
                tIlGen.EmitCallsiteCreate(tInvokeAddFuncType);
                tIlGen.Emit(OpCodes.Stsfld, tAddCallSiteField);
            }
            tIlGen.Emit(OpCodes.Ldsfld, tAddCallSiteField);
            tIlGen.Emit(OpCodes.Ldfld, tAddCallSiteField.FieldType.GetFieldEvenIfGeneric("Target"));
            tIlGen.Emit(OpCodes.Ldsfld, tAddCallSiteField);
            tIlGen.Emit(OpCodes.Ldarg_0);
            tIlGen.Emit(OpCodes.Call, typeof (ActLikeProxy).GetProperty("Original").GetGetMethod());
            for (var i = 1; i <= tAddParamTypes.Length; i++) {
                tIlGen.EmitLoadArgument(i);
            }
            tIlGen.EmitCallInvokeFunc(tInvokeAddFuncType);
            tIlGen.Emit(OpCodes.Pop);
            tIlGen.Emit(OpCodes.Ret);

            tMp.SetAddOnMethod(tAddBuilder);

            var tRemovePrefixName = tRemoveMethod.Name;
            if (!defaultImp) {
                tRemovePrefixName = String.Format("{0}.{1}", info.DeclaringType.FullName, tRemovePrefixName);
            }

            //Remove Method
            var tRemoveBuilder = typeBuilder.DefineMethod(tRemovePrefixName,
                tPublicPrivate | MethodAttributes.SpecialName | MethodAttributes.HideBySig | MethodAttributes.Virtual | MethodAttributes.Final | MethodAttributes.NewSlot,
                typeof (void),
                tAddParamTypes);
            if (!defaultImp) {
                typeBuilder.DefineMethodOverride(tRemoveBuilder, info.GetRemoveMethod());
            }

            foreach (var tParam in tRemoveMethod.GetParameters()) {
                tRemoveBuilder.DefineParameter(tParam.Position + 1, AttributesForParam(tParam), tParam.Name);
            }

            tIlGen = tRemoveBuilder.GetILGenerator();

            using (tIlGen.EmitBranchTrue(load => load.Emit(OpCodes.Ldsfld, tIsEventField))) {
                tIlGen.EmitDynamicIsEventBinder(CSharpBinderFlags.None, tName, contextType);
                tIlGen.EmitCallsiteCreate(tInvokeIseventFuncType);
                tIlGen.Emit(OpCodes.Stsfld, tIsEventField);
            }

            using (tIlGen.EmitBranchTrue(
                load => load.EmitInvocation(
                    target => target.EmitInvocation(
                        t => t.Emit(OpCodes.Ldsfld, tIsEventField),
                        i => i.Emit(OpCodes.Ldfld, tIsEventField.FieldType.GetFieldEvenIfGeneric("Target"))
                        ),
                    invoke => invoke.EmitCallInvokeFunc(tInvokeIseventFuncType),
                    param => param.Emit(OpCodes.Ldsfld, tIsEventField),
                    param => param.EmitInvocation(
                        t => t.Emit(OpCodes.Ldarg_0),
                        i => i.Emit(OpCodes.Call, typeof (ActLikeProxy).GetProperty("Original").GetGetMethod())
                        )
                    )
                )
                ) //if IsEvent Not True
            {
                using (tIlGen.EmitBranchTrue(gen => gen.Emit(OpCodes.Ldsfld, tSetField))) {
                    tIlGen.EmitDynamicSetBinderDynamicParams(CSharpBinderFlags.ValueFromCompoundAssignment, tName, contextType, tReturnType);
                    tIlGen.EmitCallsiteCreate(tInvokeSetFuncType);
                    tIlGen.Emit(OpCodes.Stsfld, tSetField);
                }

                var tSubrtractAssignField = tCallSite.GetFieldEvenIfGeneric(tInvokeSubtractAssign);

                using (tIlGen.EmitBranchTrue(gen => gen.Emit(OpCodes.Ldsfld, tSubrtractAssignField))) {
                    tIlGen.EmitDynamicBinaryOpBinder(CSharpBinderFlags.None, ExpressionType.SubtractAssign, contextType, tReturnType);
                    tIlGen.EmitCallsiteCreate(tInvokeSubtractAssignFuncType);
                    tIlGen.Emit(OpCodes.Stsfld, tSubrtractAssignField);
                }

                using (tIlGen.EmitBranchTrue(gen => gen.Emit(OpCodes.Ldsfld, tGetField))) {
                    tIlGen.EmitDynamicGetBinder(CSharpBinderFlags.None, tName, contextType);
                    tIlGen.EmitCallsiteCreate(tInvokeGetFuncType);
                    tIlGen.Emit(OpCodes.Stsfld, tGetField);
                }

                tIlGen.Emit(OpCodes.Ldsfld, tSetField);
                tIlGen.Emit(OpCodes.Ldfld, tSetField.FieldType.GetFieldEvenIfGeneric("Target"));
                tIlGen.Emit(OpCodes.Ldsfld, tSetField);
                tIlGen.Emit(OpCodes.Ldarg_0);
                tIlGen.Emit(OpCodes.Call, typeof (ActLikeProxy).GetProperty("Original").GetGetMethod());

                tIlGen.Emit(OpCodes.Ldsfld, tSubrtractAssignField);
                tIlGen.Emit(OpCodes.Ldfld, tSubrtractAssignField.FieldType.GetFieldEvenIfGeneric("Target"));
                tIlGen.Emit(OpCodes.Ldsfld, tSubrtractAssignField);

                tIlGen.Emit(OpCodes.Ldsfld, tGetField);
                tIlGen.Emit(OpCodes.Ldfld, tGetField.FieldType.GetFieldEvenIfGeneric("Target"));
                tIlGen.Emit(OpCodes.Ldsfld, tGetField);
                tIlGen.Emit(OpCodes.Ldarg_0);
                tIlGen.Emit(OpCodes.Call, typeof (ActLikeProxy).GetProperty("Original").GetGetMethod());

                tIlGen.EmitCallInvokeFunc(tInvokeGetFuncType);

                tIlGen.Emit(OpCodes.Ldarg_1);
                tIlGen.EmitCallInvokeFunc(tInvokeSubtractAssignFuncType);

                tIlGen.EmitCallInvokeFunc(tInvokeSetFuncType);

                tIlGen.Emit(OpCodes.Pop);
                tIlGen.Emit(OpCodes.Ret);
            }

            var tRemoveCallSiteField = tCallSite.GetFieldEvenIfGeneric(tInvokeRemove);
            using (tIlGen.EmitBranchTrue(gen => gen.Emit(OpCodes.Ldsfld, tRemoveCallSiteField))) {
                tIlGen.EmitDynamicMethodInvokeBinder(
                    CSharpBinderFlags.InvokeSpecialName | CSharpBinderFlags.ResultDiscarded,
                    tRemoveMethod.Name,
                    contextType,
                    tRemoveMethod.GetParameters(),
                    Enumerable.Repeat(default(string),
                        tRemoveParamTypes.Length));
                tIlGen.EmitCallsiteCreate(tInvokeRemoveFuncType);
                tIlGen.Emit(OpCodes.Stsfld, tRemoveCallSiteField);
            }
            tIlGen.Emit(OpCodes.Ldsfld, tRemoveCallSiteField);
            tIlGen.Emit(OpCodes.Ldfld, tRemoveCallSiteField.FieldType.GetFieldEvenIfGeneric("Target"));
            tIlGen.Emit(OpCodes.Ldsfld, tRemoveCallSiteField);
            tIlGen.Emit(OpCodes.Ldarg_0);
            tIlGen.Emit(OpCodes.Call, typeof (ActLikeProxy).GetProperty("Original").GetGetMethod());
            tIlGen.Emit(OpCodes.Ldarg_1);
            tIlGen.EmitCallInvokeFunc(tInvokeRemoveFuncType);
            tIlGen.Emit(OpCodes.Pop);
            tIlGen.Emit(OpCodes.Ret);

            tMp.SetRemoveOnMethod(tRemoveBuilder);
        }
Esempio n. 24
0
        /// <summary>
        /// Defines an event based on the specified event.
        /// </summary>
        /// <param name="typeBuilder">The type builder.</param>
        /// <param name="eventInfo">The event information.</param>
        /// <param name="isExplicit">A value indicating whether the specified event should be implemented explicitly.</param>
        /// <param name="methodBuilderFactory">The method builder factory function.</param>
        /// <returns>The event builder.</returns>
        public static void DefineEvent(this TypeBuilder typeBuilder,
            EventInfo eventInfo,
            bool isExplicit,
            Func<MethodInfo, bool, MethodBuilder> methodBuilderFactory)
        {
            if (typeBuilder == null)
                throw new ArgumentNullException("typeBuilder");

            if (eventInfo == null)
                throw new ArgumentNullException("eventInfo");

            if (methodBuilderFactory == null)
                throw new ArgumentNullException("methodBuilderFactory");

            // Define event.
            var eventName = isExplicit ? eventInfo.GetFullName() : eventInfo.Name;

            var eventBuilder = typeBuilder.DefineEvent(
                eventName,
                eventInfo.Attributes,
                eventInfo.EventHandlerType);

            // Build event add method.
            var addMethodInfo = eventInfo.GetAddMethod();
            var addMethodBuilder = methodBuilderFactory(addMethodInfo, isExplicit);

            eventBuilder.SetAddOnMethod(addMethodBuilder);

            // Build event remove method.
            var removeMethodInfo = eventInfo.GetRemoveMethod(true);
            var removeMethodBuilder = methodBuilderFactory(removeMethodInfo, isExplicit);

            eventBuilder.SetRemoveOnMethod(removeMethodBuilder);

            // Build event raise method.
            var raiseMethodInfo = eventInfo.GetRaiseMethod(true);

            if (raiseMethodInfo != null)
            {
                var methodBuilder = methodBuilderFactory(raiseMethodInfo, isExplicit);

                eventBuilder.SetRaiseMethod(methodBuilder);
            }

            // Build event other methods.
            var otherMethodInfos = eventInfo.GetOtherMethods(true);

            // Mono returns null in case no other methods are defined.
            if (otherMethodInfos != null)
            {
                foreach (var otherMethodInfo in otherMethodInfos)
                {
                    var methodBuilder = methodBuilderFactory(otherMethodInfo, isExplicit);

                    eventBuilder.AddOtherMethod(methodBuilder);
                }
            }
        }
Esempio n. 25
0
 public static MethodInfo?GetRemoveMethod(this EventInfo eventInfo, bool nonPublic)
 {
     ArgumentNullException.ThrowIfNull(eventInfo);
     return(eventInfo.GetRemoveMethod(nonPublic));
 }
Esempio n. 26
0
        private void AddEvent(EventInfo @event, IProxyGenerationHook hook)
        {
            var addMethod = @event.GetAddMethod(true);
            var removeMethod = @event.GetRemoveMethod(true);
            MetaMethod adder = null;
            MetaMethod remover = null;

            if (addMethod != null)
            {
                adder = AddMethod(addMethod, hook, false);
            }

            if (removeMethod != null)
            {
                remover = AddMethod(removeMethod, hook, false);
            }

            if (adder == null && remover == null)
            {
                return;
            }

            events[@event] = new MetaEvent(@event.Name,
                                           @event.DeclaringType, @event.EventHandlerType, adder, remover, EventAttributes.None);
        }
Esempio n. 27
0
 private void CreateEvent(Type aType, Classifier aCls, EventInfo anEvent, PdOOM.BasePackage aPckg, ref AttributeTable aAttrTable, ref MethodTable aMthTable, ref InfluenceTable aInfTable)
 {
     if (!LZ.Reverse.Info._bVBNet)
     {
         bool flag;
         bool flag2;
         if (aType.GetField(anEvent.Name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly) != null)
         {
             flag = false;
             flag2 = false;
         }
         else
         {
             flag = true;
             flag2 = true;
         }
         if (flag)
         {
             PdOOM.Attribute anObject = (PdOOM.Attribute) aCls.CreateObject(0x18112065, "", -1, true);
             anObject.Stereotype = "Event";
             try
             {
                 anObject.Name = anObject.Code = anEvent.Name;
             }
             catch (COMException)
             {
                 if (LZ.Reverse.Info._bDebug)
                 {
                     LZ.Reverse.Info.Write(new string[] { "*** exception while naming the event \"{1}\" on the type \"{0}\"", aType.FullName, anEvent.Name });
                 }
             }
             Type eventHandlerType = anEvent.EventHandlerType;
             this.ProcessType(eventHandlerType, false);
             TypeMapping mapping = TypeMapping.Retrieve(eventHandlerType);
             anObject.DataType = mapping.Name;
             if (!mapping.Delegate && LZ.Reverse.Info._bDebug)
             {
                 LZ.Reverse.Info.Write(new string[] { "*** invalid delegate mapping for \"{0}\"", eventHandlerType.FullName });
             }
             MethodInfo addMethod = anEvent.GetAddMethod(true);
             anObject.Visibility = GetMethodVisibility(addMethod);
             if (flag2)
             {
                 aInfTable.Add(addMethod, anObject, "EventAdd");
                 addMethod = anEvent.GetRemoveMethod(true);
                 aInfTable.Add(addMethod, anObject, "EventRemove");
             }
         }
         if (!flag2)
         {
             MethodInfo aMethod = anEvent.GetAddMethod(true);
             aMthTable.Add(aMethod);
             aMethod = anEvent.GetRemoveMethod(true);
             aMthTable.Add(aMethod);
         }
     }
 }
        private void Initialize()
        {
            assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(
                a => a.FullName.StartsWith("Microsoft.WindowsAzure.ServiceRuntime"));

            // If we are runing within a worker role Microsoft.WindowsAzure.ServiceRuntime should already be loaded
            if (assembly == null)
            {
                const string msg1 = "Microsoft.WindowsAzure.ServiceRuntime is not loaded. Trying to load it with Assembly.LoadWithPartialName().";
                logger.Warn(ErrorCode.AzureServiceRuntime_NotLoaded, msg1);

                // Microsoft.WindowsAzure.ServiceRuntime isn't loaded. We may be running within a web role or not in Azure.
                // Trying to load by partial name, so that we are not version specific.
                // Assembly.LoadWithPartialName has been deprecated. Is there a better way to load any version of a known assembly?
                #pragma warning disable 618
                assembly = Assembly.LoadWithPartialName("Microsoft.WindowsAzure.ServiceRuntime");
                #pragma warning restore 618
                if (assembly == null)
                {
                    const string msg2 = "Failed to find or load Microsoft.WindowsAzure.ServiceRuntime.";
                    logger.Error(ErrorCode.AzureServiceRuntime_FailedToLoad, msg2);
                    throw new OrleansException(msg2);
                }
            }

            roleEnvironmentType = assembly.GetType("Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment");
            stoppingEvent = roleEnvironmentType.GetEvent("Stopping");
            stoppingEventAdd = stoppingEvent.GetAddMethod();
            stoppingEventRemove = stoppingEvent.GetRemoveMethod();

            roleInstanceType = assembly.GetType("Microsoft.WindowsAzure.ServiceRuntime.RoleInstance");

            DeploymentId = (string) roleEnvironmentType.GetProperty("DeploymentId").GetValue(null);
            if (string.IsNullOrWhiteSpace(DeploymentId))
                throw new OrleansException("DeploymentId is null or whitespace.");

            currentRoleInstance = roleEnvironmentType.GetProperty("CurrentRoleInstance").GetValue(null);
            if (currentRoleInstance == null)
                throw new OrleansException("CurrentRoleInstance is null.");

            InstanceId = currentRoleInstance.Id;
            UpdateDomain = currentRoleInstance.UpdateDomain;
            FaultDomain = currentRoleInstance.FaultDomain;
            instanceEndpoints = currentRoleInstance.InstanceEndpoints;
            role = currentRoleInstance.Role;
            RoleName = role.Name;
        }
        static MethodBuilder BuildEventRemoveMethod(TypeBuilder type, Type viewType, EventInfo eventInfo)
        {
            var removeBuilder =  BuildMethod(
                type,
                "remove",
                eventInfo.Name,
                typeof(void),
                new [] { eventInfo.EventHandlerType });

            var il = removeBuilder.GetILGenerator();

            EmitILForEachView(viewType, il,
                () =>
                {
                    // Call the original remove method
                    var originalRemoveMethod = eventInfo.GetRemoveMethod();
                    il.EmitCall(OpCodes.Callvirt, originalRemoveMethod, null);
                });

            // Return control
            il.Emit(OpCodes.Ret);

            return removeBuilder;
        }
Esempio n. 30
0
        private static bool ShouldReserveName(EventInfo member)
        {
            bool hasNonPrivate = false;

            MethodInfo miAdd = member.GetAddMethod();
            if (miAdd != null)
            {
                hasNonPrivate |= ShouldReserveName(miAdd, false);
            }

            MethodInfo miRemove = member.GetRemoveMethod();
            if (miRemove != null)
            {
                hasNonPrivate |= ShouldReserveName(miRemove, false);
            }

            return hasNonPrivate;
        }
Esempio n. 31
0
        /// <summary> method checks to see if the class implements addPropertyChangeListener
        /// </summary>
        /// <returns>
        /// 
        /// </returns>
        protected internal virtual bool checkBean()
        {
            bool add = false;
            bool remove = false;

            eventPropertyChanged = OBJECT_CLASS.GetEvent("PropertyChanged");

            if (eventPropertyChanged == null)
            {
                return false;
            }

            delegateType = eventPropertyChanged.EventHandlerType;
            addListener = eventPropertyChanged.GetAddMethod();
            removeListener = eventPropertyChanged.GetRemoveMethod();

            return delegateType != null && addListener != null && removeListener != null;
            /*
            MethodInfo[] methd = INFO.getMethodDescriptors();
            for (int idx = 0; idx < methd.Length; idx++)
            {
                MethodInfo desc = methd[idx];
                if (desc.Name.Equals(Constants.PCS_ADD) && checkParameter(desc))
                {
                    // check the parameter
                    add = true;
                }
                if (desc.Name.Equals(Constants.PCS_REMOVE) && checkParameter(desc))
                {
                    // check the parameter
                    remove = true;
                }
            }
            if (add && remove)
            {
                getUtilMethods();
                return true;
            }
            else
            {
                return false;
            }
            */
        }
Esempio n. 32
0
 public override System.Reflection.MethodInfo GetRemoveMethod(bool nonPublic)
 {
     return(_innerEventInfo.GetRemoveMethod(nonPublic));
 }
Esempio n. 33
0
 public static MethodInfo?GetRemoveMethod(this EventInfo eventInfo)
 {
     ArgumentNullException.ThrowIfNull(eventInfo, nameof(eventInfo));
     return(eventInfo.GetRemoveMethod());
 }
Esempio n. 34
0
		/// <summary>Writes XML documenting an event.</summary>
		/// <param name="writer">XmlWriter to write on.</param>
		/// <param name="eventInfo">Event to document.</param>
		private void WriteEvent(XmlWriter writer, EventInfo eventInfo)
		{
			string memberName = MemberID.GetMemberID(eventInfo);

			string name = eventInfo.Name;
			string interfaceName = null;

			int lastIndexOfDot = name.LastIndexOf('.');
			if (lastIndexOfDot != -1)
			{
				//this is an explicit interface implementation. if we don't want
				//to document them, get out of here quick...
				if (!this.rep.DocumentExplicitInterfaceImplementations) return;

				interfaceName = name.Substring(0, lastIndexOfDot);
				lastIndexOfDot = interfaceName.LastIndexOf('.');
				if (lastIndexOfDot != -1)
					name = name.Substring(lastIndexOfDot + 1);

				//check if we want to document this interface.
				ImplementsInfo implements = null;
				MethodInfo adder = eventInfo.GetAddMethod(true);
				if (adder != null)
				{
					implements = implementations[adder.ToString()];
				}
				if (implements == null)
				{
					MethodInfo remover = eventInfo.GetRemoveMethod(true);
					if (remover != null)
					{
						implements = implementations[remover.ToString()];
					}
				}
				if (implements != null) return;
			}

			writer.WriteStartElement("event");
			writer.WriteAttributeString("name", name);
			writer.WriteAttributeString("id", memberName);
			writer.WriteAttributeString("access", GetMethodAccessValue(eventInfo.GetAddMethod(true)));
			writer.WriteAttributeString("contract", GetMethodContractValue(eventInfo.GetAddMethod(true)));
			Type t = eventInfo.EventHandlerType;
			writer.WriteAttributeString("type", MemberID.GetTypeName(t));
			writer.WriteAttributeString("valueType", t.IsValueType.ToString().ToLower());

			bool inherited = eventInfo.DeclaringType != eventInfo.ReflectedType;

			if (inherited)
			{
				writer.WriteAttributeString("declaringType", MemberID.GetDeclaringTypeName(eventInfo));
			}

			if (interfaceName != null)
			{
				writer.WriteAttributeString("interface", interfaceName);
			}

			if (eventInfo.IsMulticast)
			{
				writer.WriteAttributeString("multicast", "true");
			}

			if (inherited)
			{
				WriteInheritedDocumentation(writer, memberName, eventInfo.DeclaringType);
			}
			else
			{
				WriteEventDocumentation(writer, memberName, true);
			}
			WriteCustomAttributes(writer, eventInfo);

			if (implementations != null)
			{
				ImplementsInfo implements = null;
				MethodInfo adder = eventInfo.GetAddMethod(true);
				if (adder != null)
				{
					implements = implementations[adder.ToString()];
				}
				if (implements == null)
				{
					MethodInfo remover = eventInfo.GetRemoveMethod(true);
					if (remover != null)
					{
						implements = implementations[remover.ToString()];
					}
				}
				if (implements != null)
				{
					writer.WriteStartElement("implements");
					MemberInfo InterfaceMethod = (MemberInfo)implements.InterfaceMethod;
					EventInfo InterfaceEvent = 
						InterfaceMethod.DeclaringType.GetEvent(InterfaceMethod.Name.Substring(4));
					writer.WriteAttributeString("name", InterfaceEvent.Name);
					writer.WriteAttributeString("id", MemberID.GetMemberID(InterfaceEvent));
					writer.WriteAttributeString("interface", implements.InterfaceType.Name);
					writer.WriteAttributeString("interfaceId", MemberID.GetMemberID(implements.InterfaceType));
					writer.WriteAttributeString("declaringType", implements.InterfaceType.FullName.Replace('+', '.'));
					writer.WriteEndElement();
				}
			}

			writer.WriteEndElement();
		}
 private void OverrideEvent(EventInfo @event, int count)
 {
     MethodBuilder addMethod = OverrideEventMethod(@event.GetAddMethod(), count);
     MethodBuilder removeMethod = OverrideEventMethod(@event.GetRemoveMethod(), count);
     AddEventDefinition(@event, addMethod, removeMethod);
 }