Example #1
0
        public CILEvent ChangeDeclaringType(params CILTypeBase[] args)
        {
            LogicalUtils.ThrowIfDeclaringTypeNotGeneric(this, args);
            CILEvent evtToGive = this;
            CILType  dt        = this.declaringType.Value;

            if (dt.GenericDefinition != null)
            {
                evtToGive = dt.GenericDefinition.DeclaredEvents[dt.DeclaredEvents.IndexOf(this)];
            }
            return(this.context.Cache.MakeEventWithGenericType(evtToGive, args));
        }
Example #2
0
    /// <summary>
    /// Gets all the methods that are semantically related to specified <see cref="CILEvent"/>.
    /// </summary>
    /// <param name="evt">The event which methods must be semantically related to.</param>
    /// <returns>Enumerable of semantic attribute-method pairs.</returns>
    /// <exception cref="ArgumentNullException">If <paramref name="evt"/> is <c>null</c>.</exception>
    public static IEnumerable <Tuple <MethodSemanticsAttributes, CILMethod> > GetSemanticMethods(this CILEvent evt)
    {
        ArgumentValidator.ValidateNotNull("Event", evt);

        if (evt.AddMethod != null)
        {
            yield return(Tuple.Create(MethodSemanticsAttributes.AddOn, evt.AddMethod));
        }
        if (evt.RemoveMethod != null)
        {
            yield return(Tuple.Create(MethodSemanticsAttributes.RemoveOn, evt.RemoveMethod));
        }
        if (evt.RaiseMethod != null)
        {
            yield return(Tuple.Create(MethodSemanticsAttributes.Fire, evt.RaiseMethod));
        }
        foreach (var otherMethod in evt.OtherMethods.Where(m => m != null))
        {
            yield return(Tuple.Create(MethodSemanticsAttributes.Other, otherMethod));
        }
    }
Example #3
0
 /// <summary>
 /// Returns <c>true</c> if the event is multicast, that is, <see cref="MulticastDelegate"/> is assignable from event's <see cref="CILEvent.EventHandlerType"/>.
 /// </summary>
 /// <param name="evt">The event to check.</param>
 /// <returns><c>true</c> if the event is non-<c>null</c> and multicast, that is, <see cref="MulticastDelegate"/> is assignable from event's <see cref="CILEvent.EventHandlerType"/>; <c>false</c> otherwise.</returns>
 public static Boolean IsMultiCast(this CILEvent evt)
 {
     return(evt != null && evt.DeclaringType.Module.AssociatedMSCorLibModule.GetTypeByName(Consts.MULTICAST_DELEGATE).IsAssignableFrom(evt.EventHandlerType));
 }