Example #1
0
        /// <summary>
        /// Adds the event handler.
        /// </summary>
        virtual protected void AddHandler()
        {
            // We can't use AddEventHandler on AOT based platforms
#if UNITY_IPHONE || UNITY_XBOX360 || UNITY_PS3 || UNITY_PSP2 || UNITY_XBOXONE || UNITY_PS4 || UNITY_WIIU || UNITY_WEBGL
            // Used cached info
            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 addMethod = eventInfo.GetAddMethod();
                addMethod.Invoke(sendingComponent, new object[] { handler });
            }
            // Dynamically add event listener
            else
            {
                sendingComponent = sender.GetComponent(typeName);
                System.Type type = this.GetType().Assembly.GetType(this.GetType().Namespace + "." + typeName);

                if (type != null && sendingComponent != null)
                {
                    eventInfo = type.GetEvent(eventName);

                    if (eventInfo != 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 addMethod = eventInfo.GetAddMethod();
                        addMethod.Invoke(sendingComponent, new object[] { handler });
                    }
                }
            }
#else
            // Used cached info
            if (eventInfo != null && handler != null && sendingComponent != null)
            {
                eventInfo.AddEventHandler(sendingComponent, handler);
            }
            else
            {
                // Dynamically add event listener
                sendingComponent = sender.GetComponent(typeName);
                System.Type type = this.GetType().Assembly.GetType(this.GetType().Namespace + "." + typeName);

                if (type != null && sendingComponent != null)
                {
                    eventInfo = type.GetEvent(eventName);

                    if (eventInfo != 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);
                        eventInfo.AddEventHandler(sendingComponent, handler);
                    }
                }
            }
#endif
        }
Example #2
0
        public void MostrarPaginas(object formLis)
        {
            this.SuspendLayout();
            bool continua = false;

            if (formListado != null && formListado.ElementoTipo != null && formListado.ElementoTipo.Name != ((Lfc.FormularioListadoBase)formLis).ElementoTipo.Name)
            {
                continua = true;
            }
            if (!PanelPagina.Visible || continua)
            {
                PanelProgreso.Visible = false;
                PanelAyuda.Visible    = false;
                PanelPersona.Visible  = false;
                PanelArticulo.Visible = false;
                PanelPagina.Visible   = true;
                formListado           = (Lfc.FormularioListadoBase)formLis;

                if (formListado != null && formListado.Definicion != null && formListado.Definicion.Acciones != null)
                {
                    btnAction.DropDownItems.Clear();
                    int iBtn = 1;
                    foreach (string[] cad in formListado.Definicion.Acciones)
                    {
                        if (cad[0] == "Separator")
                        {
                            ToolStripSeparator itmSep = new ToolStripSeparator();
                            itmSep.Name = "sep" + iBtn.ToString() + "ToolStripMenuItem";
                            btnAction.DropDownItems.Add(itmSep);
                        }
                        else
                        {
                            ToolStripMenuItem itm = new ToolStripMenuItem();
                            itm.Name = "boton" + iBtn.ToString() + "ToolStripMenuItem";
                            itm.Size = new Size(152, 22);
                            itm.Text = cad[0];

                            if (cad.Length > 1 && cad[1].Length > 0)
                            {
                                System.Reflection.EventInfo  ei = typeof(ToolStripMenuItem).GetEvent("Click");
                                System.Reflection.MethodInfo mi = ei.GetAddMethod();
                                Delegate d = Delegate.CreateDelegate(typeof(EventHandler), formListado, cad[1]);
                                mi.Invoke(itm, new object[] { d });
                            }

                            btnAction.DropDownItems.Add(itm);
                        }
                        iBtn++;
                    }
                }

                this.ResumeLayout();
            }
        }
Example #3
0
        /// <summary>
        /// Hack for compatibility RabbitMQ.Client library between 3.4.x and 3.5.x versions
        /// ConnectionShutdownEventHandler replaced by Eventhandler<ShutdownEventArgs> - https://github.com/rabbitmq/rabbitmq-dotnet-client/commit/84ca5552a338a86c9af124331adca230accf3be3
        /// using reflection for understand, what type of delegate we must use for IConnection.ConnectionShutdown:
        /// - EventHandler<ShutdownEventArgs> for 3.5.x version
        /// - ConnectionShutdownEventHandler for 3.4.x and early version
        /// </summary>
        private void PrepareConnectionShutdownEventHandler()
        {
            System.Reflection.EventInfo connectionShutdownEventInfo = typeof(IConnection).GetEvent("ConnectionShutdown");
            _connectionShutdownEventAddMethod = connectionShutdownEventInfo.GetAddMethod();

            Type delegateType = connectionShutdownEventInfo.EventHandlerType;

            System.Reflection.MethodInfo shutdownAmqpMethodInfo = null;

            if (delegateType.IsGenericType && delegateType.GetGenericTypeDefinition() == typeof(EventHandler <>))
            {
                shutdownAmqpMethodInfo = typeof(RabbitMQ).GetMethod("ShutdownAmqp35", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            }
            else
            {
                shutdownAmqpMethodInfo = typeof(RabbitMQ).GetMethod("ShutdownAmqp", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            }

            _connectionShutdownEventHandler = Delegate.CreateDelegate(delegateType, this, shutdownAmqpMethodInfo);
        }
Example #4
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
                );
        }
Example #5
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);
        }
Example #6
0
 public IMethod GetAddMethod()
 {
     return((IMethod)_typeSystemServices.Map(_event.GetAddMethod()));
 }
Example #7
0
 public override System.Reflection.MethodInfo GetAddMethod(bool nonPublic)
 {
     return(_innerEventInfo.GetAddMethod(nonPublic));
 }
Example #8
0
 public virtual IMethod GetAddMethod()
 {
     return((IMethod)_typeSystemServices.Map(_event.GetAddMethod(true)));
 }