示例#1
0
        /// <summary>
        /// Removes the event handler.
        /// </summary>
        virtual protected void RemoveHandler()
        {
            // We can't use RemoveEventHandler on AOT based platforms
#if UNITY_IPHONE || UNITY_XBOX360 || UNITY_PS3 || UNITY_PSP2 || UNITY_XBOXONE || UNITY_PS4 || UNITY_WIIU || UNITY_WEBGL
            if (eventInfo != null && handler != null && sendingComponent != null)
            {
                System.Reflection.MethodInfo handleMethod = this.GetType().GetMethod("HandleEvent", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                handler = System.Delegate.CreateDelegate(eventInfo.EventHandlerType, this, handleMethod);
                System.Reflection.MethodInfo removeMethod = eventInfo.GetRemoveMethod();
                removeMethod.Invoke(sendingComponent, new object[] { handler });
            }
#else
            // Remove listeners
            if (eventInfo != null && handler != null && sendingComponent != null)
            {
                eventInfo.RemoveEventHandler(sendingComponent, handler);
            }
#endif
        }
示例#2
0
        internal CILEventImpl(
            CILReflectionContextImpl ctx,
            Int32 anID,
            System.Reflection.EventInfo evt)
            : base(ctx, anID, CILElementKind.Event, () => new CustomAttributeDataEventArgs(ctx, evt))
        {
            ArgumentValidator.ValidateNotNull("Event", evt);

            if (evt.DeclaringType
#if WINDOWS_PHONE_APP
                .GetTypeInfo()
#endif
                .IsGenericType&& !evt.DeclaringType
#if WINDOWS_PHONE_APP
                .GetTypeInfo()
#endif
                .IsGenericTypeDefinition)
            {
                throw new ArgumentException("This constructor may be used only on events declared in genericless types or generic type definitions.");
            }
            InitFields(
                ref this.name,
                ref this.eventAttributes,
                ref this.eventType,
                ref this.addMethod,
                ref this.removeMethod,
                ref this.raiseMethod,
                ref this.otherMethods,
                ref this.declaringType,
                new SettableValueForClasses <String>(evt.Name),
                new SettableValueForEnums <EventAttributes>((EventAttributes)evt.Attributes),
                () => ctx.Cache.GetOrAdd(evt.EventHandlerType),
                () => ctx.Cache.GetOrAdd(evt.GetAddMethod(true)),
                () => ctx.Cache.GetOrAdd(evt.GetRemoveMethod(true)),
                () => ctx.Cache.GetOrAdd(evt.GetRaiseMethod(true)),
                () => ctx.CollectionsFactory.NewListProxy <CILMethod>(ctx.LaunchEventOtherMethodsLoadEvent(new EventOtherMethodsEventArgs(evt)).Select(method => ctx.Cache.GetOrAdd(method)).ToList()),
                () => (CILType)ctx.Cache.GetOrAdd(evt.DeclaringType),
                true
                );
        }
示例#3
0
        // Imported events
        public EventExpEntry(
            System.Reflection.EventInfo eInfo,
            ISemanticResolver s
            )
        {
            Debug.Assert(eInfo != null);
            Debug.Assert(s != null);

            this.m_strName       = eInfo.Name;
            this.m_tClassDefined = s.ResolveCLRTypeToBlueType(eInfo.DeclaringType);
            this.m_type          = s.ResolveCLRTypeToBlueType(eInfo.EventHandlerType);

            this.m_node = null;

            System.Reflection.MethodInfo mAdd    = eInfo.GetAddMethod();
            System.Reflection.MethodInfo mRemove = eInfo.GetRemoveMethod();

            SetAddMethod(new MethodExpEntry(s, mAdd));
            SetRemoveMethod(new MethodExpEntry(s, mRemove));

            this.m_mods = new Modifiers(mAdd);
        }
示例#4
0
 public IMethod GetRemoveMethod()
 {
     return((IMethod)_typeSystemServices.Map(_event.GetRemoveMethod()));
 }
示例#5
0
 public override System.Reflection.MethodInfo GetRemoveMethod(bool nonPublic)
 {
     return(_innerEventInfo.GetRemoveMethod(nonPublic));
 }
示例#6
0
 public virtual IMethod GetRemoveMethod()
 {
     return((IMethod)_typeSystemServices.Map(_event.GetRemoveMethod(true)));
 }