Inheritance: ICloneable, System.Runtime.Serialization.ISerializable
 public static void AddHandler(object target, RoutedEvent routedEvent, Delegate handler, bool handledEventsToo) {
     if (null == target)
         throw new ArgumentNullException("target");
     if (null == routedEvent)
         throw new ArgumentNullException("routedEvent");
     if (null == handler)
         throw new ArgumentNullException("handler");
     //
     RoutedEventKey key = routedEvent.Key;
     if (!routedEvents.ContainsKey(key))
         throw new ArgumentException("Specified routed event is not registered.", "routedEvent");
     RoutedEventInfo routedEventInfo = routedEvents[key];
     bool needAddTarget = true;
     if (routedEventInfo.targetsList != null) {
         RoutedEventTargetInfo targetInfo = routedEventInfo.targetsList.FirstOrDefault(info => info.target == target);
         if (null != targetInfo) {
             if (targetInfo.handlersList == null)
                 targetInfo.handlersList = new List<DelegateInfo>();
             targetInfo.handlersList.Add(new DelegateInfo(handler, handledEventsToo));
             needAddTarget = false;
         }
     }
     if (needAddTarget) {
         RoutedEventTargetInfo targetInfo = new RoutedEventTargetInfo(target);
         targetInfo.handlersList = new List<DelegateInfo>();
         targetInfo.handlersList.Add(new DelegateInfo(handler, handledEventsToo));
         if (routedEventInfo.targetsList == null)
             routedEventInfo.targetsList = new List<RoutedEventTargetInfo>();
         routedEventInfo.targetsList.Add(targetInfo);
     }
 }
Esempio n. 2
0
 void InvokeUpdate(Delegate d)
 {
     if (this.IsHandleCreated)
         this.Invoke(d);
     else
         d.Method.Invoke(d.Target, null);
 }
		/*============================================================================*/
		/* Public Functions                                                           */
		/*============================================================================*/

		public void MapListener(IEventDispatcher dispatcher, Enum type, Delegate listener, Type eventClass = null)
		{
			if (eventClass == null)
			{	
				eventClass = typeof(Event);
			}

			List<EventMapConfig> currentListeners = _suspended ? _suspendedListeners : _listeners;

			EventMapConfig config;

			int i = currentListeners.Count;

			while (i-- > 0) 
			{
				config = currentListeners [i];
				if (config.Equals (dispatcher, type, listener, eventClass))
					return;
			}

			Delegate callback = eventClass == typeof(Event) ? listener : (Action<IEvent>)delegate(IEvent evt){
				RouteEventToListener(evt, listener, eventClass);
			};

			config = new EventMapConfig (dispatcher, type, listener, eventClass, callback);

			currentListeners.Add (config);

			if (!_suspended) 
			{
				dispatcher.AddEventListener (type, callback);
			}
		}
Esempio n. 4
0
 public EventOperation(Delegate assignation)
 {
     _delegateMethod = assignation.Method;
     MethodBody body = _delegateMethod.GetMethodBody();
     _stream = new MemoryStream(body.GetILAsByteArray());
     _module = _delegateMethod.Module;
 }
Esempio n. 5
0
 public unsafe bool ConnectDynamicSlot(QObject sender, string signal, Delegate slot)
 {
     this.slots.Add(slot);
     int signalId = sender.MetaObject.IndexOfSignal(QMetaObject.NormalizedSignature(signal));
     void* connection = QMetaObject.Connect(sender, signalId, this, this.slots.Count - 1 + MetaObject.MethodCount, 0, null);
     return connection != null;
 }
Esempio n. 6
0
        public static unsafe IntPtr CreateThunk(Delegate @delegate, IntPtr methodTarget)
        {
            lock (thunkAllocatorLock)
            {
                int thunkEntry = thunkNextEntry;
                Delegate thunkDelegate;
                while ((thunkDelegate = delegates[thunkEntry]) != null)
                {
                    // TODO: Use WeakReference<Delegate> instead, and check if it has been GC
                    if (++thunkEntry >= ThunkCount)
                        thunkEntry = 0;

                    // We looped, which means nothing was found
                    // TODO: We should give it another try after performing GC
                    if (thunkEntry == thunkNextEntry)
                    {
                        throw new InvalidOperationException("No thunk available");
                    }
                }

                // Setup delegate and thunk target
                // TODO: We probably want a struct instead of 2 separate arrays
                delegates[thunkEntry] = @delegate;
                GetThunkTargets()[thunkEntry] = methodTarget;

                // Return our thunk redirect function pointer
                return GetThunkPointers()[thunkEntry];                
            }
        }
Esempio n. 7
0
        protected FunctionCode EnsureFunctionCode(Delegate/*!*/ dlg) {
            Debug.Assert(dlg != null);

            if (_code == null) {
                Interlocked.CompareExchange(
                    ref _code,
                    new FunctionCode(
                        (PythonContext)SourceUnit.LanguageContext,
                        dlg,
                        null,
                        "<module>",
                        "",
                        ArrayUtils.EmptyStrings,
                        GetCodeAttributes(),
                        SourceSpan.None,
                        SourceUnit.Path,
                        false,
                        true,
                        ArrayUtils.EmptyStrings,
                        ArrayUtils.EmptyStrings,
                        ArrayUtils.EmptyStrings,
                        ArrayUtils.EmptyStrings,
                        0,
                        null,
                        null
                    ),
                    null
                );
            }
            return _code;
        }
Esempio n. 8
0
 public SourceBindingEndpoint(INotifyPropertyChanged source, Type propertyType, dynamic propertyGetter, Delegate propertySetter)
 {
     this.Source = source;
     this.PropertyType = propertyType;
     this.PropertyGetter = propertyGetter;
     this.PropertySetter = propertySetter;
 }
 public ScriptInvocationData(string fname, Delegate fn, Type[] callsig, Type returnsig)
 {
     FunctionName = fname;
     ScriptInvocationDelegate = fn;
     TypeSignature = callsig;
     ReturnType = returnsig;
 }
Esempio n. 10
0
        private static void AddTaskDelay(Delegate ev, object[] paramArray, int time)
        {
            System.Threading.Thread.Sleep(time);
            bool bFired;

            if (ev != null)
            {
                foreach (Delegate singleCast in ev.GetInvocationList())
                {
                    bFired = false;
                    try
                    {
                        ISynchronizeInvoke syncInvoke = (ISynchronizeInvoke)singleCast.Target;
                        if (syncInvoke != null && syncInvoke.InvokeRequired)
                        {
                            bFired = true;
                            syncInvoke.BeginInvoke(singleCast, paramArray);
                        }
                        else
                        {
                            bFired = true;
                            singleCast.DynamicInvoke(paramArray);
                        }
                    }
                    catch (Exception)
                    {
                        if (!bFired)
                            singleCast.DynamicInvoke(paramArray);
                    }
                }
            }
        }
Esempio n. 11
0
 internal EventListener(Enum pEvent, Delegate pCallback)
 {
     Event = pEvent;
     ListenerType = pCallback.Target.GetType();
     ListenerHashCode = pCallback.Target.GetHashCode();
     Callback = pCallback;
 }
Esempio n. 12
0
        public void AddDelegate(Type key, Delegate value)
        {
            if (key == firstKey)
            {
                throw new ArgumentException("An element with the same key already exists in the dictionary.");
            }

            if (firstKey == null && bindTo == null) // nothing
            {
                firstKey = key;
                firstValue = value;
            }
            else if (firstKey != null && bindTo == null) // one key existed
            {
                bindTo = new Dictionary<Type, Delegate>();
                bindTo.Add(firstKey, firstValue);
                firstKey = null;
                firstValue = null;
                bindTo.Add(key, value);
            }
            else
            {
                bindTo.Add(key, value);
            }
        }
Esempio n. 13
0
        // Check to see if the given delegate is a legal handler for this type.
        //  It either needs to be a type that the registering class knows how to
        //  handle, or a RoutedEventHandler which we can handle without the help
        //  of the registering class.
        internal bool IsLegalHandler(Delegate handler)
        {
            Type handlerType = handler.GetType();

            return ((handlerType == HandlerType) ||
                (handlerType == typeof(RoutedEventHandler)));
        }
Esempio n. 14
0
		public void Execute(Delegate method, DispatcherPriority priority)
		{
			if (application == null)
			{
				ExecuteDirectlyOrDuringATest(method);
				return;
			}

			var dispatcher = application.Dispatcher;

			if ((application != null) && isAsync)
			{
				dispatcher.BeginInvoke(method);
				return;
			}

			var notRequireUiThread = dispatcher.CheckAccess();

			if (notRequireUiThread)
			{
				ExecuteDirectlyOrDuringATest(method);
				return;
			}

			if (isAsync)
			{
				dispatcher.BeginInvoke(method, priority);
				return;
			}

			dispatcher.Invoke(method, priority);
		}
		public void UnmapListener(IEventDispatcher dispatcher, Enum type, Delegate listener, Type eventClass = null)
		{
			if (eventClass == null)
			{	
				eventClass = typeof(Event);
			}

			List<EventMapConfig> currentListeners = _suspended ? _suspendedListeners : _listeners;

			EventMapConfig config;

			int i = currentListeners.Count;

			while (i-- > 0) 
			{
				config = currentListeners [i];
				if (config.Equals (dispatcher, type, listener, eventClass)) 
				{
					if (!_suspended) 
					{
						dispatcher.RemoveEventListener (type, config.callback);
					}
					currentListeners.RemoveAt (i);
					return;
				}
			}
		}
Esempio n. 16
0
 public DelegateTestCase(string fixtureName, Delegate testDelegate, params object[] args)
     : base(fixtureName)
 {
     this.testDelegate = testDelegate;
     foreach (Object arg in args)
         this.Parameters.Add(new TestCaseParameter(arg));
 }
Esempio n. 17
0
        private Ptr<RPC_SERVER_INTERFACE> Configure(RpcHandle handle, Ptr<MIDL_SERVER_INFO> me, Guid iid,
                                                    Byte[] formatTypes, Byte[] formatProc, ushort[] formatProcOffsets,
                                                    Delegate[] funcs)
        {
            Ptr<RPC_SERVER_INTERFACE> svrIface = handle.CreatePtr(new RPC_SERVER_INTERFACE(handle, me, iid));
            Ptr<MIDL_STUB_DESC> stub = handle.CreatePtr(new MIDL_STUB_DESC(handle, svrIface.Handle, formatTypes, true));
            pStubDesc = stub.Handle;

            var dispatches = new IntPtr[funcs.Length];
            for (var i = 0; i < funcs.Length; ++i)
            {
              dispatches[i] = handle.PinFunction(funcs[i]);
            }
            DispatchTable = handle.Pin(dispatches);

            ProcString = handle.Pin(formatProc);
            FmtStringOffset = handle.Pin(formatProcOffsets.Clone());

            ThunkTable = IntPtr.Zero;
            pTransferSyntax = IntPtr.Zero;
            nCount = IntPtr.Zero;
            pSyntaxInfo = IntPtr.Zero;

            //Copy us back into the pinned address
            Marshal.StructureToPtr(this, me.Handle, false);
            return svrIface;
        }
 /// <summary>
 /// SignaturePointcut ctor.
 /// </summary>
 /// <param name="targetMethodSignature">Wildcard pattern of the method signatures to match</param>
 /// <param name="interceptor">Interceptor delegate to apply on matched methods, valid delegates are <c>BeforeDelegate</c>, <c>AroundDelegate</c> and <c>AfterDelegate</c></param>
 public SignaturePointcut(string targetMethodSignature, Delegate interceptor)
 {
     TargetMethodSignature = targetMethodSignature;
     ArrayList arr = new ArrayList();
     arr.Add(interceptor);
     Interceptors = arr;
 }
Esempio n. 19
0
		internal DispatcherOperation (Dispatcher dis, DispatcherPriority prio, Delegate d, object arg)
			: this (dis, prio)
		{
			delegate_method = d;
			delegate_args = new object [1];
			delegate_args [0] = arg;
		}
    public static void AddObserver(Handler handler, string notificationName, System.Object sender)
    {
        if (handler == null)
        {
            Debug.LogError("Can't add a null event handler for notification, " + notificationName);
            return;
        }

        if (string.IsNullOrEmpty(notificationName))
        {
            Debug.LogError("Can't observe an unnamed notification");
            return;
        }

        if (!instance._table.ContainsKey(notificationName))
            instance._table.Add(notificationName, new SenderTable());

        SenderTable subTable = instance._table[notificationName];

        System.Object key = (sender != null) ? sender : instance;

        if (!subTable.ContainsKey(key))
            subTable.Add(key, new List<Handler>());

        List<Handler> list = subTable[key];
        if (!list.Contains(handler))
        {
            if (_invoking.Contains(list))
                subTable[key] = list = new List<Handler>(list);

            list.Add(handler);
        }
    }
 public InterestCalculatorClass(decimal money, float interest, int years, Delegate del)
 {
     this.Money = money;
     this.Interest = interest;
     this.Years = years;
     this.dele = del;
 }
 public InvokeCompletedEventArgs(Delegate method, object[] args, object result, Exception error)
 {
     this.method = method;
     this.args = args;
     this.result = result;
     this.error = error;
 }
Esempio n. 23
0
        /// <summary>
        /// Remove the given delegate from my invocation list.
        /// </summary>
        protected override sealed Delegate Remove(Delegate other)
        {
            if (this.Equals(other))
            {
                // Front of the list
                var result = next;
                next = null;
                return result;
            }

            MulticastDelegate parent = this;
            while ((parent != null) && (!other.Equals(parent.next)))
            {
                parent = parent.next;
            }

            if (parent != null)
            {
                MulticastDelegate otherx = parent.next;
                parent.next = otherx.next;
                otherx.next = null;
            }

            return this;
        }
Esempio n. 24
0
 public static Delegate Remove(Delegate source, Delegate value)
 {
     if (source == null) {
         return null;
     }
     return source.RemoveImpl(value);
 }
Esempio n. 25
0
 public void SetJob(Delegate function,
                    object functionParameter,
                    Delegate assignResult = null,
                    JobPriority priority = JobPriority.High)
 {
     this.SetJob(new Job(function, new []{functionParameter}, assignResult), priority);
 }
Esempio n. 26
0
        //====================================================================
        // Given a true delegate instance, return the PyObject handle of the
        // Python object implementing the delegate (or IntPtr.Zero if the
        // delegate is not implemented in Python code.
        //====================================================================

        public IntPtr GetPythonHandle(Delegate d) {
            if ((d != null) && (d.Target is Dispatcher)) {
                Dispatcher disp = d.Target as Dispatcher;
                return disp.target;
            }
            return IntPtr.Zero;
        }
Esempio n. 27
0
        public string Call5(Delegate callback)
        {
            var thisArg = JsValue.Undefined;
            var arguments = new JsValue[] { 1, "foo" };

            return callback.DynamicInvoke(thisArg, arguments).ToString();
        }
 /// <summary>
 /// Forwards the BeginInvoke to the current application's <see cref="Dispatcher"/>.
 /// </summary>
 /// <param name="method">Method to be invoked.</param>
 /// <param name="arg">Arguments to pass to the invoked method.</param>
 public void BeginInvoke(Delegate method, object arg)
 {
     if (Application.Current != null)
     {
         Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, method, arg);
     }
 }
Esempio n. 29
0
        public void ConnectListener(EventType eventType, Delegate listener)
        {
            if (disposed) { return; }
            var ex = events[eventType].CheckListener(listener);
            if (ex != null)
            {
                throw ex;
            }

            if (!ConnectedListeners.ContainsKey(eventType))
            {
                ConnectedListeners[eventType] = new ConcurrentDictionary<int, Delegate>();
            }
            else if (ConnectedListeners[eventType].Values.Contains(listener))
            {
                throw new ArgumentException("'listener' has already been connected to this event type.", "listener");
            }

            if (ConnectedListeners[eventType].Count == 0)
            {
                ConnectedListeners[eventType][0] = listener;
            }
            else
            {
                var index = ConnectedListeners[eventType].Keys.Max() + 1;
                ConnectedListeners[eventType][index] = listener;
            }
        }
        static Delegate GetCreateItemHelper()
        {
            if (cb_CreateItem == null)
                cb_CreateItem = JNINativeWrapper.CreateDelegate((Func<IntPtr, IntPtr, int, IntPtr>)_CreateItem);

            return cb_CreateItem;
        }
Esempio n. 31
0
 /// <summary>
 /// Disconnects a function.
 /// </summary>
 /// <param name="func">The function to disconnect</param>
 public void Disconnect(System.Delegate func)
 {
     System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
     {
         Interop.KeyboardResizedSignalType.Disconnect(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
         if (NDalicPINVOKE.SWIGPendingException.Pending)
         {
             throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
     }
 }
Esempio n. 32
0
 public void Disconnect(System.Delegate func)
 {
     System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate <System.Delegate>(func);
     {
         Interop.ComponentApplication.CreateNativeSignalDisconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
         if (NDalicPINVOKE.SWIGPendingException.Pending)
         {
             throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
     }
 }
Esempio n. 33
0
 public void Connect(System.Delegate func)
 {
     System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate <System.Delegate>(func);
     {
         Interop.PropertyNotifySignal.PropertyNotifySignal_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
         if (NDalicPINVOKE.SWIGPendingException.Pending)
         {
             throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
     }
 }
Esempio n. 34
0
 public void Disconnect(System.Delegate func)
 {
     System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate <System.Delegate>(func);
     {
         NDalicManualPINVOKE.PreFocusChangeSignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
         if (NDalicPINVOKE.SWIGPendingException.Pending)
         {
             throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
     }
 }
Esempio n. 35
0
 public void Disconnect(System.Delegate func)
 {
     System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate <System.Delegate>(func);
     {
         Interop.CubeTransitionEffect.CubeTransitionEffectSignalDisconnect(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
         if (NDalicPINVOKE.SWIGPendingException.Pending)
         {
             throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
     }
 }
Esempio n. 36
0
 public override void InvokeEventHandler(System.Delegate handler, object target)
 {
     if (handler is SelectionChangedEventHandler)
     {
         ((SelectionChangedEventHandler)handler)(target, this);
     }
     else
     {
         base.InvokeEventHandler(handler, target);
     }
 }
Esempio n. 37
0
            private Expression Evaluate(Expression e)
            {
                if (e.NodeType == ExpressionType.Constant)
                {
                    return(e);
                }
                LambdaExpression lambda = Expression.Lambda(e);

                System.Delegate fn = lambda.Compile();
                return(Expression.Constant(fn.DynamicInvoke(null), e.Type));
            }
        public virtual void Dispose()
        {
            this.Close();

            this._Username = null;
            this._Password = null;
            this._Domain   = null;
            this._Method   = null;

            return;
        }
Esempio n. 39
0
            /// <summary>
            /// Remove the given event handler of the given event.
            /// </summary>
            /// <param name="instance"></param>
            /// <param name="delegateInstance"></param>
            internal void Remove(object instance, System.Delegate eventHandler)
            {
                lock (@lock)
                {
                    if (debug)
                    {
                        DEBUG("Remove " + this.forEvent.ToString() + " from instance=" + instance == null ? "null" : instance.ToString());
                    }

                    this.forEvent.RemoveEventHandler(instance, eventHandler);
                }
            }
Esempio n. 40
0
 static public int get_Target(IntPtr l)
 {
     try {
         System.Delegate self = (System.Delegate)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.Target);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 41
0
        public static bool AddBinding(Type bindFrom, Type bindTo, sysDel bindFunction)
        {
            BindingPair binding = new BindingPair(bindFrom, bindTo);

            if (Bindings.ContainsKey(binding))
            {
                Debug.Fail("Could not add binding for " + bindFrom.Name + " and " + bindTo.Name + " as a binding already exists");
                return(false);
            }

            Bindings.Add(binding, bindFunction);
            return(true);
        }
Esempio n. 42
0
        /// <summary>
        /// A template method that queues an action with three payloads
        /// </summary>
        /// <typeparam name="A">First payload type</typeparam>
        /// <typeparam name="B">Second payload type</typeparam>
        /// <typeparam name="C">Third payload type</typeparam>
        /// <param name="a">Payload 1</param>
        /// <param name="b">Payload 2</param>
        /// <param name="c">Payload 3</param>
        /// <param name="callback">A callback function to be called when the delegate is invoked </param>
        public static void Call <A, B, C>(A a, B b, C c, System.Delegate callback)
        {
            if (callback != null)
            {
                System.Action <A, B, C> call = delegate(A arg1, B arg2, C arg3)
                {
                    DispatchPayload3 <A, B, C> newDispatch = new DispatchPayload3 <A, B, C>(arg1, arg2, arg3, Cast <Action <A, B, C> >(callback));
                    actionQueue.Enqueue(newDispatch);
                };

                call(a, b, c);
            }
        }
Esempio n. 43
0
        /// <summary>
        /// A method that queues an action without a payload
        /// </summary>
        /// <param name="callback">A callback function to be called when the delegate is invoked </param>
        public static void Call(System.Delegate callback)
        {
            if (callback != null)
            {
                System.Action call = delegate
                {
                    DispatchNoPayload newDispatch = new DispatchNoPayload(Cast <Action>(callback));
                    actionQueue.Enqueue(newDispatch);
                };

                call();
            }
        }
Esempio n. 44
0
        /// <summary>
        /// A template method that queues an action with a single payload
        /// </summary>
        /// <typeparam name="A">Payload type</typeparam>
        /// <param name="a">Payload 1</param>
        /// <param name="callback">A callback function to be called when the delegate is invoked </param>
        public static void Call <A>(A a, System.Delegate callback)
        {
            if (callback != null)
            {
                System.Action <A> call = delegate(A arg1)
                {
                    DispatchPayload1 <A> newDispatch = new DispatchPayload1 <A>(arg1, Cast <Action <A> >(callback));
                    actionQueue.Enqueue(newDispatch);
                };

                call(a);
            }
        }
Esempio n. 45
0
    public void AddListener <T> (EventDelegate <T> del) where T : GameLocalEvent
    {
        if (_delegates.ContainsKey(typeof(T)))
        {
            System.Delegate tempDel = _delegates[typeof(T)];

            _delegates[typeof(T)] = System.Delegate.Combine(tempDel, del);
        }
        else
        {
            _delegates[typeof(T)] = del;
        }
    }
Esempio n. 46
0
        /// <summary>
        /// Ensures that the function passed in is called from the main loop when it is idle.
        /// </summary>
        /// <param name="func">The function to call</param>
        /// <returns>true if added successfully, false otherwise</returns>
        public bool AddIdle(System.Delegate func)
        {
            System.IntPtr ip  = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate <System.Delegate>(func);
            System.IntPtr ip2 = Interop.Application.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));

            bool ret = Interop.Application.Application_AddIdle(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));

            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Esempio n. 47
0
    static ProjectBrowserDragAndDrop()
    {
        //Assign a custom drop handler delegate
        Type projectBrowserDropHandler = dragAndDropServiceType.GetNestedType("ProjectBrowserDropHandler");

        MethodInfo handlerMethodInfo = typeof(ProjectBrowserDragAndDrop).GetMethod("CustomProjectBrowserDropHandler", BindingFlags.Static | BindingFlags.NonPublic);

        System.Delegate delegateTest = System.Delegate.CreateDelegate(projectBrowserDropHandler, handlerMethodInfo);

        MethodInfo methodInfo = dragAndDropServiceType.GetMethod("AddDropHandler", new Type[] { projectBrowserDropHandler });

        methodInfo.Invoke(null, new object[] { delegateTest });
    }
Esempio n. 48
0
    public void AddListener <T>(string eventName, EventDelegate <T> del) where T : BaseEvent
    {
        if (delegates.ContainsKey(eventName))
        {
            System.Delegate tempDel = delegates[eventName];

            delegates[eventName] = Delegate.Combine(tempDel, del);
        }
        else
        {
            delegates[eventName] = del;
        }
    }
Esempio n. 49
0
 static public int GetInvocationList(IntPtr l)
 {
     try {
         System.Delegate self = (System.Delegate)checkSelf(l);
         var             ret  = self.GetInvocationList();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 50
0
    //////// - Nguyễn Việt Dũng : Anh em chú ý nhé. (BỎ COMMENT RA KHI MUỐN BIẾT SỰ KIỆN PHÁT SINH TỪ ĐÂU) - ////////////
    string LogEvent(System.Delegate _event)
    {
        if (_event == null)
        {
            return("");
        }
        string strDebug = "Event: " + _event.ToString() + " ->\n";

        foreach (System.Delegate _delegate in _event.GetInvocationList())
        {
            strDebug += "" + _delegate.Method.ReflectedType.Name + " : " + _delegate.Method.Name + "\n";
        }
        return(strDebug);
    }
Esempio n. 51
0
 /// <summary>
 /// Only use the Dispatcher if we are not already on the UI Thread.
 /// This avoid WPF exceptions saying the dispatcher is unavailable.
 /// </summary>
 /// <param name="d">The delegate to invoke</param>
 /// <param name="args">Optional parameters</param>
 public static object Invoke(System.Delegate d, params object[] args)
 {
     if (dispatcher != null && System.Threading.Thread.CurrentThread.ManagedThreadId != uiThreadId)
     {
         // Note: must be careful using this method, it could deadlock the UI, so make sure
         // it cannot be interleaved with similar calls.
         return(dispatcher.Invoke(d, args));
     }
     else
     {
         // we are already on the UI thread so call the delegate directly.
         return(d.DynamicInvoke(args));
     }
 }
Esempio n. 52
0
        protected System.Delegate IncrementListeners(System.Delegate existingListeners, System.Delegate newListener)
        {
#if DEBUG
            this.AddListener(newListener);
#endif
            // Add the new listener and if we still don't have a listener (don't know why) return...
            System.Delegate result = System.Delegate.Combine(existingListeners, newListener);
            if (null == result)
            {
                return(result);
            }

            return(result);
        }
Esempio n. 53
0
 private void AddEventHandler(Type t, System.Delegate handler, DelegateType dt)
 {
     if (handlers[dt].ContainsKey(t))
     {
         handlers[dt][t].Add(new PEventWeakDelegate(handler));
     }
     else
     {
         handlers[dt].Add(t, new List <PEventWeakDelegate>()
         {
             new PEventWeakDelegate(handler)
         });
     }
 }
Esempio n. 54
0
        public DynamicCondition(Expression expression, IEnumerable <DynamicConditionParameter> parameters)
        {
            this.parameters = new List <DynamicConditionParameter>(parameters);

            typeMap = this.parameters?.Select(x => x.Type).Select(Type.GetType).ToArray();


            var ps = this.parameters?.Select((x, i) => Expression.Parameter(typeMap[i], x.Name))
                     .ToArray();

            var lambda = Expression.Lambda(expression, ps);

            function = lambda.Compile();
        }
 private object DynamicInvokeCommand(System.Delegate commandDelegate, object[] agrs)
 {
     // execute
     try
     {
         object ret = commandDelegate.DynamicInvoke(agrs);
         return(ret);
     }
     catch (Exception exc)
     {
         // throw inner exception if exists
         throw (exc.InnerException != null ? exc.InnerException: exc);
     }
 }
Esempio n. 56
0
        public static System.IAsyncResult BeginInvokeMSS(
            System.Windows.Forms.Control target,
            System.Delegate method)
        {
            object result;

            if (TestSpecificStubsUtil.RunTestSpecificStub(System.Reflection.MethodBase.GetCurrentMethod(), new object[] { target, method }, out result))
            {
                return((System.IAsyncResult)result);
            }
            else
            {
                return(target.BeginInvoke(method));
            }
        }
Esempio n. 57
0
 static int GetDelegateName(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Delegate arg0 = (System.Delegate)ToLua.CheckObject(L, 1, typeof(System.Delegate));
         string          o    = Util.GetDelegateName(arg0);
         LuaDLL.lua_pushstring(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 58
0
 static int GetHashCode(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Delegate obj = (System.Delegate)ToLua.CheckObject <System.Delegate>(L, 1);
         int             o   = obj.GetHashCode();
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 59
0
 static int Clone(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Delegate obj = (System.Delegate)ToLua.CheckObject(L, 1, typeof(System.Delegate));
         object          o   = obj.Clone();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 60
0
 static int GetInvocationList(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Delegate   obj = (System.Delegate)ToLua.CheckObject <System.Delegate>(L, 1);
         System.Delegate[] o   = obj.GetInvocationList();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }