コード例 #1
0
        internal void WireupAutomaticEvents()
        {
            if (!SupportAutoEvents || !AutoEventWireup)
            {
                return;
            }

            /* Avoid expensive reflection operations by computing the event info only once */
            Type      type   = GetType();
            ArrayList events = auto_event_info.InsertOrGet((uint)type.GetHashCode(), type, null, CollectAutomaticEventInfo);

            for (int i = 0; i < events.Count; ++i)
            {
                EvtInfo evinfo = (EvtInfo)events [i];
                if (evinfo.noParams)
                {
                    NoParamsInvoker npi = new NoParamsInvoker(this, evinfo.method);
                    evinfo.evt.AddEventHandler(this, npi.FakeDelegate);
                }
                else
                {
                    evinfo.evt.AddEventHandler(this, Delegate.CreateDelegate(typeof(EventHandler), this, evinfo.method));
                }
            }
        }
コード例 #2
0
ファイル: TemplateControl.cs プロジェクト: raj581/Marvin
        internal void WireupAutomaticEvents()
        {
            if (!SupportAutoEvents || !AutoEventWireup)
            {
                return;
            }

            ArrayList events = null;

            /* Avoid expensive reflection operations by computing the event info only once */
            lock (auto_event_info_monitor) {
                if (auto_event_info == null)
                {
                    auto_event_info = new Hashtable();
                }
                events = (ArrayList)auto_event_info [GetType()];
                if (events == null)
                {
                    events = CollectAutomaticEventInfo();
                    auto_event_info [GetType()] = events;
                }
            }

            for (int i = 0; i < events.Count; ++i)
            {
                EvtInfo evinfo = (EvtInfo)events [i];
                if (evinfo.noParams)
                {
                    NoParamsInvoker npi = new NoParamsInvoker(this, evinfo.method);
                    evinfo.evt.AddEventHandler(this, npi.FakeDelegate);
                }
                else
                {
                    evinfo.evt.AddEventHandler(this, Delegate.CreateDelegate(
#if NET_2_0
                                                   typeof(EventHandler), this, evinfo.method));
#else
                                                   typeof(EventHandler), this, evinfo.methodName));
#endif
                }
            }
        }
コード例 #3
0
ファイル: TemplateControl.cs プロジェクト: nlhepler/mono
		internal void WireupAutomaticEvents ()
		{
			if (!SupportAutoEvents || !AutoEventWireup)
				return;

			/* Avoid expensive reflection operations by computing the event info only once */
			Type type = GetType ();
			ArrayList events = auto_event_info.InsertOrGet ((uint)type.GetHashCode (), type, null, CollectAutomaticEventInfo);

			for (int i = 0; i < events.Count; ++i) {
				EvtInfo evinfo = (EvtInfo)events [i];
				if (evinfo.noParams) {
					NoParamsInvoker npi = new NoParamsInvoker (this, evinfo.method);
					evinfo.evt.AddEventHandler (this, npi.FakeDelegate);
				} else
					evinfo.evt.AddEventHandler (this, Delegate.CreateDelegate (typeof (EventHandler), this, evinfo.method));
			}
		}
コード例 #4
0
ファイル: TemplateControl.cs プロジェクト: stabbylambda/mono
		internal void WireupAutomaticEvents ()
		{
			if (!SupportAutoEvents || !AutoEventWireup)
				return;

			ArrayList events = null;

			/* Avoid expensive reflection operations by computing the event info only once */
			lock (auto_event_info_monitor) {
				if (auto_event_info == null)
					auto_event_info = new Hashtable ();
				events = (ArrayList)auto_event_info [GetType ()];
				if (events == null) {
					events = CollectAutomaticEventInfo ();
					auto_event_info [GetType ()] = events;
				}
			}

			for (int i = 0; i < events.Count; ++i) {
				EvtInfo evinfo = (EvtInfo)events [i];
				if (evinfo.noParams) {
					NoParamsInvoker npi = new NoParamsInvoker (this, evinfo.method);
					evinfo.evt.AddEventHandler (this, npi.FakeDelegate);
				} else
					evinfo.evt.AddEventHandler (this, Delegate.CreateDelegate (typeof (EventHandler), this, evinfo.method));
			}
		}