예제 #1
0
        public void AddDelegate(Delegate d)
        {
            if (args_type == null)
            {
                args_type = d.Method.GetParameters()[1].ParameterType;
            }

            if (d.Method.IsDefined(typeof(ConnectBeforeAttribute), false))
            {
                before_handler = Delegate.Combine(before_handler, d);
                if (before_closure == null)
                {
                    if (marshaler == null)
                    {
                        before_closure = new SignalClosure(obj.Handle, name, args_type);
                    }
                    else
                    {
                        before_closure = new SignalClosure(obj.Handle, name, marshaler, this);
                    }
                    before_closure.Disposed += ClosureDisposedHandler;
                    before_closure.Invoked  += ClosureInvokedHandler;
                    before_closure.Connect(false);
                }
            }
            else
            {
                after_handler = Delegate.Combine(after_handler, d);
                if (after_closure == null)
                {
                    if (marshaler == null)
                    {
                        after_closure = new SignalClosure(obj.Handle, name, args_type);
                    }
                    else
                    {
                        after_closure = new SignalClosure(obj.Handle, name, marshaler, this);
                    }
                    after_closure.Disposed += ClosureDisposedHandler;
                    after_closure.Invoked  += ClosureInvokedHandler;
                    after_closure.Connect(true);
                }
            }
        }
        public void AddDelegate(Delegate d)
        {
            if (args_type == null)
            {
                args_type = d.Method.GetParameters()[1].ParameterType;
            }

            if (d.Method.IsDefined(typeof(ConnectBeforeAttribute), false))
            {
                tref.Target.BeforeSignals [name] = Delegate.Combine(tref.Target.BeforeSignals [name] as Delegate, d);
                if (before_closure == null)
                {
                    if (marshaler == null)
                    {
                        before_closure = new SignalClosure(this, args_type);
                    }
                    else
                    {
                        before_closure = new SignalClosure(this, marshaler);
                    }
                    before_closure.Disposed += ClosureDisposedHandler;
                    before_closure.Invoked  += ClosureInvokedHandler;
                    before_closure.Connect(false);
                }
            }
            else
            {
                tref.Target.AfterSignals [name] = Delegate.Combine(tref.Target.AfterSignals [name] as Delegate, d);
                if (after_closure == null)
                {
                    if (marshaler == null)
                    {
                        after_closure = new SignalClosure(this, args_type);
                    }
                    else
                    {
                        after_closure = new SignalClosure(this, marshaler);
                    }
                    after_closure.Disposed += ClosureDisposedHandler;
                    after_closure.Invoked  += ClosureInvokedHandler;
                    after_closure.Connect(true);
                }
            }
        }